================== idAsyncServer::ProcessMessage ================== */
| 2175 | ================== |
| 2176 | */ |
| 2177 | bool idAsyncServer::ProcessMessage( const netadr_t from, idBitMsg &msg ) { |
| 2178 | int i, id, sequence; |
| 2179 | idBitMsg outMsg; |
| 2180 | byte msgBuf[MAX_MESSAGE_SIZE]; |
| 2181 | |
| 2182 | id = msg.ReadShort(); |
| 2183 | |
| 2184 | // check for a connectionless message |
| 2185 | if ( id == CONNECTIONLESS_MESSAGE_ID ) { |
| 2186 | return ConnectionlessMessage( from, msg ); |
| 2187 | } |
| 2188 | |
| 2189 | if ( msg.GetRemaingData() < 4 ) { |
| 2190 | common->DPrintf( "%s: tiny packet\n", Sys_NetAdrToString( from ) ); |
| 2191 | return false; |
| 2192 | } |
| 2193 | |
| 2194 | // find out which client the message is from |
| 2195 | for ( i = 0; i < MAX_ASYNC_CLIENTS; i++ ) { |
| 2196 | serverClient_t &client = clients[i]; |
| 2197 | |
| 2198 | if ( client.clientState == SCS_FREE ) { |
| 2199 | continue; |
| 2200 | } |
| 2201 | |
| 2202 | // This does not compare the UDP port, because some address translating |
| 2203 | // routers will change that at arbitrary times. |
| 2204 | if ( !Sys_CompareNetAdrBase( from, client.channel.GetRemoteAddress() ) || id != client.clientId ) { |
| 2205 | continue; |
| 2206 | } |
| 2207 | |
| 2208 | // make sure it is a valid, in sequence packet |
| 2209 | if ( !client.channel.Process( from, serverTime, msg, sequence ) ) { |
| 2210 | return false; // out of order, duplicated, fragment, etc. |
| 2211 | } |
| 2212 | |
| 2213 | // zombie clients still need to do the channel processing to make sure they don't |
| 2214 | // need to retransmit the final reliable message, but they don't do any other processing |
| 2215 | if ( client.clientState == SCS_ZOMBIE ) { |
| 2216 | return false; |
| 2217 | } |
| 2218 | |
| 2219 | client.lastPacketTime = serverTime; |
| 2220 | |
| 2221 | ProcessReliableClientMessages( i ); |
| 2222 | ProcessUnreliableClientMessage( i, msg ); |
| 2223 | |
| 2224 | return false; |
| 2225 | } |
| 2226 | |
| 2227 | // if we received a sequenced packet from an address we don't recognize, |
| 2228 | // send an out of band disconnect packet to it |
| 2229 | outMsg.Init( msgBuf, sizeof( msgBuf ) ); |
| 2230 | outMsg.WriteShort( CONNECTIONLESS_MESSAGE_ID ); |
| 2231 | outMsg.WriteString( "disconnect" ); |
| 2232 | serverPort.SendPacket( from, outMsg.GetData(), outMsg.GetSize() ); |
| 2233 | |
| 2234 | return false; |
nothing calls this directly
no test coverage detected