Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

trunk: some virtuals

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