Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/network_stream.h @ 6981

Last change on this file since 6981 was 6981, checked in by bensch, 18 years ago

trunk: some virtuals

File size: 2.2 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
[5647]17class Synchronizeable;
18class NetworkSocket;
[6139]19class ServerSocket;
[5647]20class ConnectionMonitor;
[5741]21class NetworkProtocol;
[6341]22class NetworkGameManager;
[5589]23
[6139]24typedef std::list<Synchronizeable*>  SynchronizeableList;
25typedef std::vector<NetworkSocket*>  NetworkSocketVector;
26typedef std::vector<Handshake*>      HandshakeVector;
[5809]27
28
[5649]29class NetworkStream : public DataStream
[5566]30{
31
[5996]32  public:
33    NetworkStream();
[6139]34    NetworkStream(IPaddress& address);
35    NetworkStream(unsigned int port);
[5804]36
[6981]37    virtual ~NetworkStream();
[5996]38    void init();
[5804]39
[6695]40    void createNetworkGameManager();
41    void startHandshake();
42
[5996]43    void connectSynchronizeable(Synchronizeable& sync);
[6139]44    void disconnectSynchronizeable(Synchronizeable& sync);
[5566]45
[5996]46    inline bool isServer() const { return (this->type == NET_SERVER)? true:false; }
47    inline bool isActive() const { return this->bActive; }
48
[6139]49    inline int getMaxConnections(){ return maxConnections; }
50    void setMaxConnections( int n );
51
[5996]52    virtual void processData();
53
[6341]54    inline SynchronizeableList::const_iterator getSyncBegin(){ return synchronizeables.begin(); }
55    inline SynchronizeableList::const_iterator getSyncEnd(){ return synchronizeables.end(); }
[6695]56    int getSyncCount();
[6341]57
[6634]58    inline bool isUserIdActive( int userID ) { if (userID>=networkSockets.size()) return false; else return networkSockets[userID]!=NULL; }
59
[6695]60    void debug();
61
62
[5996]63  private:
[6695]64    void updateConnectionList();
[6139]65
66
[6695]67  private:
68    NetworkProtocol*           networkProtocol;
69    ConnectionMonitor*         connectionMonitor;
70    SynchronizeableList        synchronizeables;
71    NetworkSocketVector        networkSockets;
72    HandshakeVector            handshakes;
73    ServerSocket*              serverSocket;
74    int                        type;
75    Header                     packetHeader;
76    bool                       bActive;
77    std::list<int>             freeSocketSlots;
[6341]78
[6695]79    int                        myHostId;
80    int                        maxConnections;
81
82    NetworkGameManager*        networkGameManager;
[5587]83};
[5566]84#endif /* _NETWORK_STREAM */
Note: See TracBrowser for help on using the repository browser.