Game Development Reference
In-Depth Information
NetMsg_PlayerLoginOk,
};
// server accepting a client
RemoteEventSocket(SOCKET new_sock, unsigned int hostIP)
: NetSocket(new_sock, hostIP) { }
// client attach to server
RemoteEventSocket() { };
virtual void VHandleInput();
protected:
void CreateEvent(std::istrstream &in);
};
void RemoteEventSocket::VHandleInput()
{
NetSocket::VHandleInput();
// traverse the list of m_InList packets and do something useful with them
while (!m_InList.empty())
{
shared_ptr<IPacket> packet = *m_InList.begin();
m_InList.pop_front();
const char *buf = packet->VGetData();
int size = static_cast<int>(packet->VGetSize());
std::istrstream in(buf+sizeof(u_long), (size-sizeof(u_long)));
int type;
in >> type;
switch(type)
{
case NetMsg_Event:
CreateEvent(in);
break;
case NetMsg_PlayerLoginOk:
{
int serverSockId, actorId;
in >> serverSockId;
in >> actorId;
shared_ptr<EvtData_Network_Player_Actor_Assignment> pEvent
(GCC_NEW EvtData_Network_Player_Actor_Assignment(actorId,
serverSockId));
IEventManager::Get()->VQueueEvent(pEvent);
Search WWH ::




Custom Search