Esempio n. 1
0
bool Protocol::Response(Packet& inPacket)
{
	if (inPacket.m_bCheckSumError)
	{
		return generalRespons(inPacket, GeneralResponsePacket::ERROR_MESSAGE);
	}

	if (!bAuthorized && inPacket.GetMessageID() != Packet::TERMINAL_REGIST
			&& inPacket.GetMessageID() != Packet::TERMINAL_AUTHORIZE)
	{
		m_bCloseConnect = true;
		return false;
	}

	return dispatch(inPacket);
}
Esempio n. 2
0
bool Protocol::dispatch(Packet& inPacket)
{
	bool bResponsed = false;

	switch (inPacket.GetMessageID())
	{
	case Packet::TERMINAL_REGIST:
		bResponsed = onRegist(inPacket);
		break;
	case Packet::MESSAGE_UNKNOWN:
		TRACE("unknown message");
		m_bCloseConnect = true;
		break;
	case Packet::TERMINAL_AUTHORIZE:
		//FIXME:set according to onAuthorize result;
		bAuthorized = true;
		bResponsed = generalRespons(inPacket, onAuthorize(inPacket));
		break;
	case Packet::TERMINAL_GENERAL_HEARTBEAT:
		bResponsed = generalRespons(inPacket,GeneralResponsePacket::SUCCESS);
		break;
	default:
		bResponsed = generalRespons(inPacket,
				GeneralResponsePacket::NO_SUPPORTED);
		break;
	}
	return bResponsed;
}