Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

network: now every entity gets a network uniqueID

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