Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/network/network_stream.h @ 6659

Last change on this file since 6659 was 6659, checked in by patrick, 18 years ago

network: the Synchronizeables now all get connected

File size: 2.3 KB
RevLine 
[5566]1/*!
2 * @file network_stream.h
3 *  implementation of a network pipe
4 */
[5587]5
[5566]6#ifndef _NETWORK_STREAM
7#define _NETWORK_STREAM
8
[6139]9#include <vector>
10#include <list>
11
[5582]12#include "data_stream.h"
[5809]13#include "network_protocol.h"
[6139]14#include "server_socket.h"
15#include "handshake.h"
[5566]16
[6341]17#define MAX_CONNECTIONS 1000
18
[5647]19class Synchronizeable;
20class NetworkSocket;
[6139]21class ServerSocket;
[5647]22class ConnectionMonitor;
[5741]23class NetworkProtocol;
[6341]24class NetworkGameManager;
[5589]25
[6139]26typedef std::list<Synchronizeable*>  SynchronizeableList;
27typedef std::vector<NetworkSocket*>  NetworkSocketVector;
28typedef std::vector<Handshake*>      HandshakeVector;
[5809]29
30
[5649]31class NetworkStream : public DataStream
[5566]32{
33
[5996]34  public:
35    NetworkStream();
[6139]36    NetworkStream(IPaddress& address);
37    NetworkStream(unsigned int port);
[5804]38
[5996]39    ~NetworkStream();
40    void init();
[5804]41
[6659]42    void createNetworkGameManager();
43
[5996]44    void connectSynchronizeable(Synchronizeable& sync);
[6139]45    void disconnectSynchronizeable(Synchronizeable& sync);
[5566]46
[5996]47    inline bool isServer() const { return (this->type == NET_SERVER)? true:false; }
48    inline bool isActive() const { return this->bActive; }
49
[6139]50    inline int getMaxConnections(){ return maxConnections; }
51    void setMaxConnections( int n );
52
[5996]53    virtual void processData();
54
[6341]55    inline SynchronizeableList::const_iterator getSyncBegin(){ return synchronizeables.begin(); }
56    inline SynchronizeableList::const_iterator getSyncEnd(){ return synchronizeables.end(); }
57    inline int getSyncCount(){ return synchronizeables.size(); }
58
[6634]59    inline bool isUserIdActive( int userID ) { if (userID>=networkSockets.size()) return false; else return networkSockets[userID]!=NULL; }
60
[6658]61    void debug();
62
63
[5996]64  private:
[6658]65    void updateConnectionList();
[6139]66
67
[6658]68  private:
69    NetworkProtocol*           networkProtocol;
70    ConnectionMonitor*         connectionMonitor;
71    SynchronizeableList        synchronizeables;
72    NetworkSocketVector        networkSockets;
73    HandshakeVector            handshakes;
74    ServerSocket*              serverSocket;
75    int                        type;
76    Header                     packetHeader;
77    bool                       bActive;
78    std::list<int>             freeSocketSlots;
[6341]79
[6658]80    int                        myHostId;
81    int                        maxConnections;
82
83    NetworkGameManager*        networkGameManager;
[5587]84};
[5566]85#endif /* _NETWORK_STREAM */
Note: See TracBrowser for help on using the repository browser.