MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / processPacketReceiveEvent

Method processPacketReceiveEvent

Engine/source/sim/netInterface.cpp:86–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86void NetInterface::processPacketReceiveEvent(NetAddress srcAddress, RawData packetData)
87{
88
89 U32 dataSize = packetData.size;
90 BitStream pStream(packetData.data, dataSize);
91
92 // Determine what to do with this packet:
93
94 if(packetData.data[0] & 0x01) // it's a protocol packet...
95 {
96 // if the LSB of the first byte is set, it's a game data packet
97 // so pass it to the appropriate connection.
98
99 // lookup the connection in the addressTable
100 NetConnection *conn = NetConnection::lookup(&srcAddress);
101 if(conn)
102 conn->processRawPacket(&pStream);
103 }
104 else
105 {
106 // Otherwise, it's either a game info packet or a
107 // connection handshake packet.
108
109 U8 packetType;
110 pStream.read(&packetType);
111 NetAddress *addr = &srcAddress;
112
113 if(packetType <= GameHeartbeat || packetType == MasterServerExtendedListResponse)
114 handleInfoPacket(addr, packetType, &pStream);
115#ifdef GGC_PLUGIN
116 else if (packetType == GGCPacket)
117 {
118 HandleGGCPacket(addr, (U8*)packetData.data, dataSize);
119 }
120#endif
121 else
122 {
123 // check if there's a connection already:
124 switch(packetType)
125 {
126 case ConnectChallengeRequest:
127 handleConnectChallengeRequest(addr, &pStream);
128 break;
129 case ConnectRequest:
130 handleConnectRequest(addr, &pStream);
131 break;
132 case ConnectChallengeResponse:
133 handleConnectChallengeResponse(addr, &pStream);
134 break;
135 case ConnectAccept:
136 handleConnectAccept(addr, &pStream);
137 break;
138 case Disconnect:
139 handleDisconnect(addr, &pStream);
140 break;
141 case ConnectReject:
142 handleConnectReject(addr, &pStream);
143 break;

Callers

nothing calls this directly

Calls 4

lookupFunction · 0.85
switchFunction · 0.85
processRawPacketMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected