Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8727 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 22, 2006, 3:17:53 PM (18 years ago)
Author:
rennerc
Message:

server identifies user by his random byte

Location:
branches/network/src/lib/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/udp_server_socket.cc

    r8723 r8727  
    170170 * @param ip users host / port
    171171 */
    172 void UdpServerSocket::initUser( int userId, IPaddress ip )
     172void UdpServerSocket::initUser( int userId, IPaddress ip, byte randomByte )
    173173{
    174174  int channel = SDLNet_UDP_Bind( socket, userId, &ip );
     
    189189    userList.resize( userId + 1 );
    190190
    191   userList[ userId ] = ip;
     191  userList[ userId ].addr = ip;
     192  userList[ userId ].randomByte = randomByte;
    192193}
    193194
     
    203204    return;
    204205
    205   userList[userId].host = 0;
    206   userList[userId].port = 0;
     206  userList[userId].addr.host = 0;
     207  userList[userId].addr.port = 0;
    207208
    208209  SDLNet_UDP_Unbind( socket, userId );
     
    248249    bool isNewConnection = false;
    249250
     251    if ( packet->len <= 0 )
     252      continue;
     253       
    250254    for ( userId =0; userId < (int)userList.size(); userId++ )
    251       if ( userList[userId].host == packet->address.host && userList[userId].port == packet->address.port )
     255      if ( userList[userId].addr.host == packet->address.host && userList[userId].addr.port == packet->address.port && userList[userId].randomByte == ( packet->data[0] & 0xFC ) )
    252256        break;
    253257
    254258    if ( userId >= (int)userList.size() )
    255259    {
    256       if ( packet->len <= 0 )
    257         continue;
    258        
    259260      newConn++;
    260261      isNewConnection = true;
     
    267268
    268269      for ( userId =0; userId < (int)userList.size(); userId++ )
    269         if ( userList[userId].host == 0 && userList[userId].port == 0 )
     270        if ( userList[userId].addr.host == 0 && userList[userId].addr.port == 0 )
    270271          break;
    271272
    272       initUser( userId, packet->address );
     273      initUser( userId, packet->address, packet->data[0] & 0xFC );
    273274      UdpSocket * sock = new UdpSocket( this, packet->address, userId, packet->data[0] & 0xFC );
    274275      newSocketList.push_back( sock );
  • branches/network/src/lib/network/udp_server_socket.h

    r7954 r8727  
    3333typedef std::vector<NetworkPacketList> PacketBuffer;
    3434
    35 typedef std::vector<IPaddress> UserList;
     35struct UserInfo
     36{
     37  IPaddress addr;
     38  byte randomByte;
     39};
     40
     41typedef std::vector<UserInfo> UserList;
    3642
    3743typedef std::list<UdpSocket*> UdpSocketList;
     
    5763    bool sendPacket( NetworkPacket networkPacket, int userId );
    5864    int getPacketCount( int childId );
    59     void initUser( int childId, IPaddress ip );
     65    void initUser( int childId, IPaddress ip, byte randomByte );
    6066   
    6167  private:
Note: See TracChangeset for help on using the changeset viewer.