Changeset 9461 in orxonox.OLD
- Timestamp:
- Jul 25, 2006, 5:39:49 PM (18 years ago)
- Location:
- branches/proxy/src/lib/network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/udp_server_socket.cc
r9460 r9461 269 269 int newConn = 0; 270 270 271 // iterate through all newly received packets and assign them to the users packet buffer 271 272 for ( res = SDLNet_UDP_Recv( socket, packet ); res == 1; res = SDLNet_UDP_Recv( socket, packet ) ) 272 273 { … … 277 278 continue; 278 279 279 for ( userId =0; userId < (int)userList.size(); userId++ ) 280 if ( userList[userId].addr.host == packet->address.host && userList[userId].addr.port == packet->address.port && userList[userId].randomByte == ( packet->data[0] & 0xFC ) ) 280 // search the user id this backet belongs to 281 for ( userId = 0; userId < (int)userList.size(); userId++ ) 282 { 283 if ( userList[userId].addr.host == packet->address.host && 284 userList[userId].addr.port == packet->address.port && 285 userList[userId].randomByte == ( packet->data[0] & 0xFC ) ) 281 286 break; 282 287 } 288 289 // is it a new packet initializing a new connecion? 283 290 if ( userId >= (int)userList.size() ) 284 291 { … … 302 309 } 303 310 304 //add new packet to packetbuffer 305 311 312 // add new packet to packetbuffer 306 313 NetworkPacket networkPacket; 307 314 networkPacket.length = packet->len; -
branches/proxy/src/lib/network/udp_server_socket.h
r9460 r9461 33 33 typedef std::vector<NetworkPacketList> PacketBuffer; 34 34 35 36 //!< informations struct for each user 35 37 struct UserInfo 36 38 { 37 IPaddress addr;38 byte randomByte;39 IPaddress addr; //!< ip address of this user 40 byte randomByte; //!< random byte of this user 39 41 }; 42 40 43 41 44 typedef std::vector<UserInfo> UserList; … … 43 46 typedef std::list<UdpSocket*> UdpSocketList; 44 47 48 49 //!< the upd server socket listening for incoming connections 45 50 class UdpServerSocket : public ServerSocket 46 51 { … … 49 54 virtual ~UdpServerSocket(); 50 55 56 /* server socket manipulations */ 51 57 virtual bool listen( unsigned int port ); 52 53 58 virtual NetworkSocket* getNewClientSocket( void ); 54 59 virtual NetworkSocket* getNewProxySocket( void ); 60 virtual void close(); 55 61 56 virtual void close();57 62 58 63 virtual void update(); 59 64 65 /* network traffic interface */ 66 NetworkPacket getPacket( int userId ); 67 void removeUser( int userId ); 68 bool sendPacket( NetworkPacket networkPacket, int userId ); 69 70 71 private: 60 72 void removeUserPackets( int userId ); 61 void removeUser( int userId );62 NetworkPacket getPacket( int userId );63 bool sendPacket( NetworkPacket networkPacket, int userId );64 73 int getPacketCount( int childId ); 65 74 void initUser( int childId, IPaddress ip, byte randomByte ); 66 75 76 67 77 private: 68 UDPsocket socket; //!< will be uses to send/recieve data69 UDPpacket * packet; //!< packet structure to recieve packet70 PacketBuffer packetBuffer; //!< will store recieved packets for UdpSockets71 UserList userList; //!< contains information about clients72 UdpSocketList newSocketList; //!< contains new socket78 UDPsocket socket; //!< will be uses to send/recieve data 79 UDPpacket * packet; //!< packet structure to recieve packet 80 PacketBuffer packetBuffer; //!< will store recieved packets for UdpSockets 81 UserList userList; //!< contains information about clients 82 UdpSocketList newSocketList; //!< contains new socket 73 83 74 84 };
Note: See TracChangeset
for help on using the changeset viewer.