void RemoteEventSocket::VHandleInput() { NetSocket::VHandleInput(); while (!m_InList.empty()) { std::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; std::shared_ptr<EvtData_Network_Player_Actor_Assignment> pEvent(GCC_NEW EvtData_Network_Player_Actor_Assignment(actorId, serverSockId)); IEventManager::Get()->VQueueEvent(pEvent); break; } default: GCC_ERROR("Unknown message type.\n"); } } }
// // RemoteEventSocket::VHandleInput - Chapter 19, page 688 // 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(); if (!strcmp(packet->VGetType(), BinaryPacket::g_Type)) { 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; //in >> QuicksandEngine::g_pApp->m_Options.m_Level; // [mrmike] This was the best spot to set the level ! in >> GET_CONFIG_ELEMENT_STR("LEVEL"); shared_ptr<EvtData_Network_Player_Actor_Assignment> pEvent(QSE_NEW EvtData_Network_Player_Actor_Assignment(actorId, serverSockId)); IEventManager::Get()->VQueueEvent(pEvent); break; } default: LOG_ERROR("Unknown message type."); } } else if (!strcmp(packet->VGetType(), TextPacket::g_Type)) { std::stringstream ss; ss << "Network" << packet->VGetData() + sizeof(u_long); LOG_WRITE(ss.str()); } }