bool CRPCHandler::HandlePacket(CPacket * pPacket) { // Is it an rpc packet? if(pPacket->packetId == PACKET_RPC) { // Construct the bit stream CBitStream bitStream(pPacket->ucData, pPacket->uiLength, false); RPCIdentifier rpcId; // Read the rpc id if(bitStream.Read(rpcId)) { RPCFunction * pFunction = GetFunctionFromIdentifier(rpcId); // Does the function exist? if(pFunction) { // Call the function pFunction->rpcFunction(&bitStream, pPacket->playerSocket); return true; } } } // Not handled return false; }
void CPacketHandler::RemoveFunction(PacketIdentifier packetId) { // Get the function PacketFunction * pFunction = GetFunctionFromIdentifier(packetId); // Is the function not added? if(!pFunction) return; // Remove it from the packet function list m_packetFunctionList.remove(pFunction); // Delete it delete pFunction; }
void CRPCHandler::RemoveFunction(RPCIdentifier rpcId) { // Get the function RPCFunction * pFunction = GetFunctionFromIdentifier(rpcId); // Is the function not added? if(!pFunction) return; // Remove it from the rpc function list m_rpcFunctionList.remove(pFunction); // Delete it delete pFunction; }
bool CPacketHandler::HandlePacket(CPacket * pPacket) { PacketFunction * pFunction = GetFunctionFromIdentifier(pPacket->packetId); // Does the function exist? if(pFunction) { // Construct the bit stream CBitStream bitStream(pPacket->ucData, pPacket->uiLength, false); // Call the function pFunction->packetFunction(&bitStream, pPacket->pPlayerSocket); return true; } // Not handled return false; }
void CPacketHandler::AddFunction(PacketIdentifier packetId, PacketFunction_t packetFunction) { // Make sure it isn't already added PacketFunction * pFunction = GetFunctionFromIdentifier(packetId); if(pFunction) { // Function already added return; } // Create the packet function pFunction = new PacketFunction; pFunction->packetId = packetId; pFunction->packetFunction = packetFunction; // Add it to the packet function list m_packetFunctionList.push_back(pFunction); }
void CRPCHandler::AddFunction(RPCIdentifier rpcId, RPCFunction_t rpcFunction) { // Make sure it isn't already added RPCFunction * pFunction = GetFunctionFromIdentifier(rpcId); if(pFunction) { // Function already added return; } // Create the rpc function pFunction = new RPCFunction; pFunction->rpcId = rpcId; pFunction->rpcFunction = rpcFunction; // Add it to the rpc function list m_rpcFunctionList.push_back(pFunction); }