Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9461 in orxonox.OLD for branches/proxy


Ignore:
Timestamp:
Jul 25, 2006, 5:39:49 PM (18 years ago)
Author:
patrick
Message:

working on a dual connection server socket

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

Legend:

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

    r9460 r9461  
    269269  int newConn = 0;
    270270
     271  // iterate through all newly received packets and assign them to the users packet buffer
    271272  for ( res = SDLNet_UDP_Recv( socket, packet ); res == 1; res = SDLNet_UDP_Recv( socket, packet ) )
    272273  {
     
    277278      continue;
    278279
    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 ) )
    281286        break;
    282 
     287    }
     288
     289    // is it a new packet initializing a new connecion?
    283290    if ( userId >= (int)userList.size() )
    284291    {
     
    302309    }
    303310
    304     //add new packet to packetbuffer
    305 
     311
     312    // add new packet to packetbuffer
    306313    NetworkPacket networkPacket;
    307314    networkPacket.length = packet->len;
  • branches/proxy/src/lib/network/udp_server_socket.h

    r9460 r9461  
    3333typedef std::vector<NetworkPacketList> PacketBuffer;
    3434
     35
     36//!< informations struct for each user
    3537struct UserInfo
    3638{
    37   IPaddress addr;
    38   byte randomByte;
     39  IPaddress     addr;            //!< ip address of this user
     40  byte          randomByte;      //!< random byte of this user
    3941};
     42
    4043
    4144typedef std::vector<UserInfo> UserList;
     
    4346typedef std::list<UdpSocket*> UdpSocketList;
    4447
     48
     49//!< the upd server socket listening for incoming connections
    4550class UdpServerSocket : public ServerSocket
    4651{
     
    4954    virtual ~UdpServerSocket();
    5055
     56    /* server socket manipulations */
    5157    virtual bool listen( unsigned int port );
    52 
    5358    virtual NetworkSocket* getNewClientSocket( void );
    5459    virtual NetworkSocket* getNewProxySocket( void );
     60    virtual void close();
    5561
    56     virtual void close();
    5762
    5863    virtual void update();
    5964
     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:
    6072    void removeUserPackets( int userId );
    61     void removeUser( int userId );
    62     NetworkPacket getPacket( int userId );
    63     bool sendPacket( NetworkPacket networkPacket, int userId );
    6473    int getPacketCount( int childId );
    6574    void initUser( int childId, IPaddress ip, byte randomByte );
    6675
     76
    6777  private:
    68     UDPsocket     socket;           //!< will be uses to send/recieve data
    69     UDPpacket *   packet;           //!< packet structure to recieve packet
    70     PacketBuffer  packetBuffer;     //!< will store recieved packets for UdpSockets
    71     UserList      userList;         //!< contains information about clients
    72     UdpSocketList newSocketList;    //!< contains new socket
     78    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
    7383
    7484};
Note: See TracChangeset for help on using the changeset viewer.