Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6658 in orxonox.OLD for branches/network/src


Ignore:
Timestamp:
Jan 23, 2006, 2:43:50 PM (19 years ago)
Author:
patrick
Message:

network: debug function for NetworkStream and connection

Location:
branches/network/src
Files:
8 edited

Legend:

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

    r6654 r6658  
    2525
    2626#include "debug.h"
    27 
     27#include "shell_command.h"
    2828
    2929/* include your own header */
     
    3333/* using namespace std is default, this needs to be here */
    3434using namespace std;
     35
     36SHELL_COMMAND(debug, NetworkManager, debug);
    3537
    3638
     
    112114  this->bGameServer = true;
    113115  this->defaultSyncStream = new NetworkStream(port);
     116  PRINTF(0)("CREATE SERVER\n");
    114117  this->bGameServer = true;
    115118  SDL_Delay(20);
     
    142145void NetworkManager::connectSynchronizeable(Synchronizeable& sync)
    143146{
    144   this->defaultSyncStream->connectSynchronizeable(sync);
     147  if( this->defaultSyncStream)
     148    this->defaultSyncStream->connectSynchronizeable(sync);
    145149}
    146150
     
    170174    this->hostID = id;
    171175}
     176
     177
     178
     179/**
     180 * debug output
     181 */
     182 void NetworkManager::debug()
     183{
     184  this->defaultSyncStream->debug();
     185}
  • branches/network/src/lib/network/network_manager.h

    r6654 r6658  
    5353    inline NetworkStream* getDefaultSyncStream() { return this->defaultSyncStream; }
    5454
     55    void debug();
     56
    5557
    5658  private:
  • branches/network/src/lib/network/network_stream.cc

    r6634 r6658  
    8484  // setUniqueID( maxCon+2 ) because we need one id for every handshake
    8585  // and one for handshake to reject client maxCon+1
    86   this->networkGameManager->setUniqueID( this->maxConnections+2 );
     86  this->networkGameManager->setUniqueID( this->maxConnections + 2 );
    8787  this->connectSynchronizeable( *(this->networkGameManager) );
    8888
     
    141141}
    142142
     143
    143144void NetworkStream::disconnectSynchronizeable(Synchronizeable& sync)
    144145{
     
    216217  /* DOWNSTREAM */
    217218
     219
     220
    218221  int dataLength;
    219222  int reciever;
     
    221224  for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++)
    222225  {
    223     if ( (*it)!=NULL /*&& (*it)->getOwner() == myHostId*/ )
     226    if ( (*it)!=NULL && (*it)->beSynchronized() /*&& (*it)->getOwner() == myHostId*/ )
    224227    {
    225228      do {
     
    416419
    417420
     421
     422void NetworkStream::debug()
     423{
     424  PRINT(0)("=================NetworkStream::debug()====\n");
     425  PRINT(0)(" Host ID: %i\n", this->myHostId);
     426
     427  PRINT(0)(" Connected Synchronizeables:\n");
     428  for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++)
     429  {
     430    PRINT(0)("  Synchronizeable of class: %s::%s, with unique ID: %i\n", (*it)->getClassName(), (*it)->getName(), (*it)->getUniqueID());
     431  }
     432
     433  PRINT(0)(" Maximal Connections: %i\n", this->maxConnections);
     434  PRINT(0)("===========================================\n");
     435
     436}
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
  • branches/network/src/lib/network/network_stream.h

    r6634 r6658  
    5757    inline bool isUserIdActive( int userID ) { if (userID>=networkSockets.size()) return false; else return networkSockets[userID]!=NULL; }
    5858
     59    void debug();
     60
     61
    5962  private:
    60     NetworkProtocol*       networkProtocol;
    61     ConnectionMonitor*     connectionMonitor;
    62     SynchronizeableList    synchronizeables;
    63     NetworkSocketVector    networkSockets;
    64     HandshakeVector        handshakes;
    65     ServerSocket*          serverSocket;
    66     int                    type;
    67     Header                 packetHeader;
    68     bool                   bActive;
    69     std::list<int>         freeSocketSlots;
     63    void updateConnectionList();
    7064
    71     int                    myHostId;
    72     int                    maxConnections;
    7365
    74     NetworkGameManager*   networkGameManager;
     66  private:
     67    NetworkProtocol*           networkProtocol;
     68    ConnectionMonitor*         connectionMonitor;
     69    SynchronizeableList        synchronizeables;
     70    NetworkSocketVector        networkSockets;
     71    HandshakeVector            handshakes;
     72    ServerSocket*              serverSocket;
     73    int                        type;
     74    Header                     packetHeader;
     75    bool                       bActive;
     76    std::list<int>             freeSocketSlots;
    7577
    76     void updateConnectionList();
     78    int                        myHostId;
     79    int                        maxConnections;
     80
     81    NetworkGameManager*        networkGameManager;
    7782};
    7883#endif /* _NETWORK_STREAM */
  • branches/network/src/lib/network/synchronizeable.cc

    r6424 r6658  
    1818
    1919#include "synchronizeable.h"
     20
    2021#include "netdefs.h"
    2122#include "network_manager.h"
     23#include "network_game_manager.h"
    2224#include "network_stream.h"
     25
     26#include "assert.h"
    2327
    2428
     
    2933{
    3034  this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");
    31   owner = 0;
    32   state = 0;
    33   hostID = NetworkManager::getInstance()->getHostID();
     35  this->owner = 0;
     36  this->state = 0;
     37  this->hostID = NetworkManager::getInstance()->getHostID();
    3438  this->setIsServer(this->hostID == 0);
    35   uniqueID = -1;
     39  this->uniqueID = -1;
    3640  this->networkStream = NULL;
    3741  this->setRequestedSync( false );
    3842  this->setIsOutOfSync( !(this->isServer()) );
     43
     44  this->bSynchronize = false;
     45  NetworkStream* nd;
     46  if( this->isA(CL_NETWORK_GAME_MANAGER))
     47  {
     48    nd = NetworkGameManager::getInstance()->getNetworkStream();
     49    assert(nd != NULL);
     50    nd->connectSynchronizeable(*this);
     51  }
    3952}
    4053
     
    5063}
    5164
     65
    5266/**
    5367 *  write data to NetworkStream
     
    5771  PRINTF(5)("Synchronizeable::writeBytes was called\n");
    5872}
     73
    5974
    6075/**
     
    87102}
    88103
     104
    89105/**
    90106 * Sets the outofsync flag to a given value
     
    100116}
    101117
     118
    102119/**
    103120 * Determines if the server flag is set
     
    108125  return (this->state & STATE_SERVER) >0;
    109126}
     127
    110128
    111129/**
     
    118136}
    119137
     138
    120139/**
    121140 * Determines if the requestedSync flag is set
     
    126145  return (this->state & STATE_REQUESTEDSYNC) >0;
    127146}
     147
    128148
    129149/**
  • branches/network/src/lib/network/synchronizeable.h

    r6654 r6658  
    197197
    198198    inline void setNetworkStream(NetworkStream* stream) { this->networkStream = stream; }
     199    inline NetworkStream* getNetworkStream() { return this->networkStream; }
    199200
    200201
     
    210211    bool              bSynchronize;
    211212
    212     std::list<int> synchronizeRequests;
     213    std::list<int>    synchronizeRequests;
    213214
    214215};
  • branches/network/src/orxonox.cc

    r6426 r6658  
    280280    NetworkManager::getInstance()->createServer(port);
    281281  }
    282 
    283282  return 0;
    284283}
  • branches/network/src/world_entities/playable.cc

    r6589 r6658  
    3636  // the reference to the Current Player is NULL, because we dont have one at the beginning.
    3737  this->currentPlayer = NULL;
    38 }
     38
     39  this->setSynchronized(true);
     40}
     41
     42
    3943
    4044Playable::~Playable()
     
    5761}
    5862
     63
    5964void Playable::removeWeapon(Weapon* weapon)
    6065{
     
    6368    this->weaponConfigChanged();
    6469}
     70
    6571
    6672void Playable::nextWeaponConfig()
     
    7076}
    7177
     78
    7279void Playable::previousWeaponConfig()
    7380{
     
    7683}
    7784
     85
    7886void Playable::weaponConfigChanged()
    7987{
     
    8189    this->currentPlayer->weaponConfigChanged();
    8290}
     91
    8392
    8493/**
Note: See TracChangeset for help on using the changeset viewer.