void ServerApplication::HandlePacket(SerialPacket* const argPacket) { switch(argPacket->type) { //heartbeat system case SerialPacketType::PING: hPing(static_cast<ServerPacket*>(argPacket)); break; case SerialPacketType::PONG: hPong(static_cast<ServerPacket*>(argPacket)); break; //client connections case SerialPacketType::BROADCAST_REQUEST: hBroadcastRequest(static_cast<ServerPacket*>(argPacket)); break; case SerialPacketType::JOIN_REQUEST: hJoinRequest(static_cast<ClientPacket*>(argPacket)); break; case SerialPacketType::LOGIN_REQUEST: hLoginRequest(static_cast<ClientPacket*>(argPacket)); break; //client disconnections case SerialPacketType::LOGOUT_REQUEST: hLogoutRequest(static_cast<ClientPacket*>(argPacket)); break; case SerialPacketType::DISCONNECT_REQUEST: hDisconnectRequest(static_cast<ClientPacket*>(argPacket)); break; //server commands case SerialPacketType::ADMIN_DISCONNECT_FORCED: hAdminDisconnectForced(static_cast<ClientPacket*>(argPacket)); break; case SerialPacketType::ADMIN_SHUTDOWN_REQUEST: hAdminShutdownRequest(static_cast<ClientPacket*>(argPacket)); break; //data management & queries case SerialPacketType::REGION_REQUEST: hRegionRequest(static_cast<RegionPacket*>(argPacket)); break; case SerialPacketType::QUERY_CHARACTER_EXISTS: hQueryCharacterExists(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::QUERY_CHARACTER_STATS: hQueryCharacterStats(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::QUERY_CHARACTER_LOCATION: hQueryCharacterLocation(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::QUERY_MONSTER_EXISTS: hQueryMonsterExists(static_cast<MonsterPacket*>(argPacket)); break; case SerialPacketType::QUERY_MONSTER_STATS: hQueryMonsterStats(static_cast<MonsterPacket*>(argPacket)); break; case SerialPacketType::QUERY_MONSTER_LOCATION: hQueryMonsterLocation(static_cast<MonsterPacket*>(argPacket)); break; //character management case SerialPacketType::CHARACTER_CREATE: hCharacterCreate(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::CHARACTER_DELETE: hCharacterDelete(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::CHARACTER_LOAD: hCharacterLoad(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::CHARACTER_UNLOAD: hCharacterUnload(static_cast<CharacterPacket*>(argPacket)); break; //character movement case SerialPacketType::CHARACTER_MOVEMENT: hCharacterMovement(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::CHARACTER_ATTACK: hCharacterAttack(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::CHARACTER_DAMAGE: hCharacterDamage(static_cast<CharacterPacket*>(argPacket)); break; //chat case SerialPacketType::TEXT_BROADCAST: hTextBroadcast(static_cast<TextPacket*>(argPacket)); break; case SerialPacketType::TEXT_SPEECH: hTextSpeech(static_cast<TextPacket*>(argPacket)); break; case SerialPacketType::TEXT_WHISPER: hTextWhisper(static_cast<TextPacket*>(argPacket)); break; //handle errors default: { std::ostringstream msg; msg << "Unknown SerialPacketType encountered in the server: "; msg << static_cast<int>(argPacket->type); throw(std::runtime_error(msg.str())); } break; } }
void World::HandlePacket(SerialPacket* const argPacket) { switch(argPacket->type) { //heartbeat system case SerialPacketType::PING: heartbeatUtility.hPing(static_cast<ServerPacket*>(argPacket)); break; case SerialPacketType::PONG: heartbeatUtility.hPong(static_cast<ServerPacket*>(argPacket)); break; //game server connections case SerialPacketType::LOGOUT_RESPONSE: hLogoutResponse(static_cast<ClientPacket*>(argPacket)); break; case SerialPacketType::DISCONNECT_RESPONSE: hDisconnectResponse(static_cast<ClientPacket*>(argPacket)); break; case SerialPacketType::ADMIN_DISCONNECT_FORCED: hAdminDisconnectForced(static_cast<ClientPacket*>(argPacket)); break; //map management case SerialPacketType::REGION_CONTENT: hRegionContent(static_cast<RegionPacket*>(argPacket)); break; //character management case SerialPacketType::CHARACTER_UPDATE: hCharacterUpdate(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::CHARACTER_CREATE: hCharacterCreate(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::CHARACTER_UNLOAD: hCharacterUnload(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::QUERY_CHARACTER_EXISTS: hQueryCharacterExists(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::CHARACTER_MOVEMENT: hCharacterMovement(static_cast<CharacterPacket*>(argPacket)); break; case SerialPacketType::CHARACTER_REJECTION: hCharacterRejection(static_cast<TextPacket*>(argPacket)); break; //creature management case SerialPacketType::CREATURE_UPDATE: hCreatureUpdate(static_cast<CreaturePacket*>(argPacket)); break; case SerialPacketType::CREATURE_CREATE: hCreatureCreate(static_cast<CreaturePacket*>(argPacket)); break; case SerialPacketType::CREATURE_UNLOAD: hCreatureUnload(static_cast<CreaturePacket*>(argPacket)); break; case SerialPacketType::QUERY_CREATURE_EXISTS: hQueryCreatureExists(static_cast<CreaturePacket*>(argPacket)); break; case SerialPacketType::CREATURE_MOVEMENT: hCreatureMovement(static_cast<CreaturePacket*>(argPacket)); break; //barrier management case SerialPacketType::BARRIER_UPDATE: hBarrierUpdate(static_cast<BarrierPacket*>(argPacket)); break; case SerialPacketType::BARRIER_CREATE: hBarrierCreate(static_cast<BarrierPacket*>(argPacket)); break; case SerialPacketType::BARRIER_UNLOAD: hBarrierUnload(static_cast<BarrierPacket*>(argPacket)); break; case SerialPacketType::QUERY_BARRIER_EXISTS: hQueryBarrierExists(static_cast<BarrierPacket*>(argPacket)); break; //chat case SerialPacketType::TEXT_BROADCAST: hTextBroadcast(static_cast<TextPacket*>(argPacket)); break; case SerialPacketType::TEXT_SPEECH: hTextSpeech(static_cast<TextPacket*>(argPacket)); break; case SerialPacketType::TEXT_WHISPER: hTextWhisper(static_cast<TextPacket*>(argPacket)); break; //general rejection messages case SerialPacketType::REGION_REJECTION: case SerialPacketType::QUERY_REJECTION: throw(fatal_error(static_cast<TextPacket*>(argPacket)->text)); break; case SerialPacketType::SHUTDOWN_REJECTION: throw(std::runtime_error(static_cast<TextPacket*>(argPacket)->text)); break; //errors default: { std::ostringstream msg; msg << "Unknown SerialPacketType encountered in World: " << static_cast<int>(argPacket->type); throw(std::runtime_error(msg.str())); } break; } }