Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9604 in orxonox.OLD for branches/proxy/src/lib


Ignore:
Timestamp:
Jul 29, 2006, 11:22:58 AM (18 years ago)
Author:
patrick
Message:

started implementation for soft connections

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

Legend:

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

    r9600 r9604  
    112112  // create the network stream
    113113  this->networkStream = new NetworkStream(NET_MASTER_SERVER);
    114   this->networkStream->createServer( port, port + 1);
     114  this->networkStream->createServer( port, port + 1, port + 2);
    115115
    116116  // start the network game manager
     
    142142
    143143  // then start the server
    144   this->networkStream->createServer( port, port +1);
     144  this->networkStream->createServer( port, port + 1, port + 2);
    145145
    146146  // and to the other proxy servers also, this would be very nice if its works
  • branches/proxy/src/lib/network/network_stream.cc

    r9601 r9604  
    113113  this->setClassID(CL_NETWORK_STREAM, "NetworkStream");
    114114  this->clientSocket = NULL;
     115  this->clientSoftSocket = NULL;
    115116  this->proxySocket = NULL;
    116117  this->networkGameManager = NULL;
     
    144145  if ( this->clientSocket )
    145146  {
    146     clientSocket->close();
    147     delete clientSocket;
    148     clientSocket = NULL;
     147    this->clientSocket->close();
     148    delete this->clientSocket;
     149    this->clientSocket = NULL;
     150  }
     151  if ( this->clientSoftSocket )
     152  {
     153    this->clientSoftSocket->close();
     154    delete this->clientSoftSocket;
     155    this->clientSoftSocket = NULL;
    149156  }
    150157  if ( this->proxySocket)
     
    229236 * @param port: interface port for all clients
    230237 */
    231 void NetworkStream::createServer(int clientPort, int proxyPort)
     238void NetworkStream::createServer(int clientPort, int proxyPort, int clientSoftPort)
    232239{
    233240  PRINTF(0)(" Creating new Server: listening for clients on port %i and for proxies on port %i", clientPort, proxyPort);
    234241  this->clientSocket= new UdpServerSocket(clientPort);
     242  this->clientSoftSocket= new UdpServerSocket(clientSoftPort);
    235243  this->proxySocket = new UdpServerSocket(proxyPort);
    236244}
     
    326334    if ( this->clientSocket )
    327335      this->clientSocket->update();
     336    if ( this->clientSoftSocket)
     337      this->clientSoftSocket->update();
    328338    if( this->proxySocket)
    329339      this->proxySocket->update();
     
    336346    if ( this->clientSocket )
    337347      this->clientSocket->update();
     348    if ( this->clientSoftSocket)
     349      this->clientSoftSocket->update();
    338350    if( this->proxySocket)
    339351      this->proxySocket->update();
     
    424436  }
    425437
     438  if( this->clientSoftSocket != NULL)
     439  {
     440    tempNetworkSocket = this->clientSoftSocket->getNewSocket();
     441
     442    // we got new NET_CLIENT connecting
     443    if ( tempNetworkSocket )
     444    {
     445
     446      // this creates a new entry in the peers list
     447      peers[userId].socket = tempNetworkSocket;
     448      peers[userId].nodeType = NET_CLIENT;
     449
     450      // handle the newly connected client
     451      this->handleSoftConnect(userId);
     452
     453      PRINTF(0)("New Client softly connected: %d :D\n", userId);
     454    }
     455  }
     456
    426457
    427458  if( this->proxySocket != NULL)
     
    540571  this->peers[userId].ip = this->peers[userId].socket->getRemoteAddress();
    541572}
     573
     574
     575/**
     576 * this handles new soft connections
     577 * @param userId: the id of the new user node
     578 *
     579 * soft connections are connections from clients that are already in the network and don't need a new handshake etc.
     580 * the state of all entitites owned by userId are not deleted and stay
     581 * soft connections can not be redirected therefore they are negotiated between the to parties
     582 */
     583void NetworkStream::handleSoftConnect( int userId)
     584{
     585  // create new handshake and init its variables
     586  this->peers[userId].handshake = NULL;
     587  this->peers[userId].handshake->setUniqueID(userId);
     588
     589  this->peers[userId].connectionMonitor = new ConnectionMonitor( userId );
     590  this->peers[userId].userId = userId;
     591  this->peers[userId].bLocal = true;
     592
     593  PRINTF(0)("num sync: %d\n", synchronizeables.size());
     594
     595  // the connecting node of course is a client
     596  this->peers[userId].ip = this->peers[userId].socket->getRemoteAddress();
     597}
     598
    542599
    543600
  • branches/proxy/src/lib/network/network_stream.h

    r9600 r9604  
    4444    void connectToMasterServer(std::string host, int port);
    4545    void connectToProxyServer(int proxyId, std::string host, int port);
    46     void createServer(int clientPort, int proxyPort);
     46    void createServer(int clientPort, int proxyPort, int clientSoftPort);
    4747
    4848    void createNetworkGameManager();
     
    101101
    102102    void handleConnect( int userId);
     103    void handleSoftConnect( int userId);
    103104    void handleReconnect( int userId );
    104105    void handleDisconnect( int userId );
     
    117118    NetworkMonitor*            networkMonitor;              //!< the network monitor
    118119    NetworkGameManager*        networkGameManager;          //!< reference to the network game manager
    119     ServerSocket*              clientSocket;                //!< the listening socket of the server
     120    ServerSocket*              clientSocket;                //!< the listening socket for clients of the server
     121    ServerSocket*              clientSoftSocket;            //!< the listening socket for soft connections to the server
    120122    ServerSocket*              proxySocket;                 //!< socket for proxy connections
    121123
Note: See TracChangeset for help on using the changeset viewer.