Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6190 was 6190, checked in by rennerc, 18 years ago

synchronizeable: added sender parameter to writeBytes
network_stream: creates now a network_game_manager
network_game_manager: implemented some functions

File size: 1.9 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    ~NetworkStream();
38    void init();
39
40    void connectSynchronizeable(Synchronizeable& sync);
41    void disconnectSynchronizeable(Synchronizeable& sync);
42
43    inline bool isServer() const { return (this->type == NET_SERVER)? true:false; }
44    inline bool isActive() const { return this->bActive; }
45
46    inline int getMaxConnections(){ return maxConnections; }
47    void setMaxConnections( int n );
48
49    virtual void processData();
50
51    inline SynchronizeableList::const_iterator getSyncBegin(){ return synchronizeables.begin(); }
52    inline SynchronizeableList::const_iterator getSyncEnd(){ return synchronizeables.end(); }
53
54  private:
55    NetworkProtocol*       networkProtocol;
56    ConnectionMonitor*     connectionMonitor;
57    SynchronizeableList    synchronizeables;
58    NetworkSocketVector    networkSockets;
59    HandshakeVector        handshakes;
60    ServerSocket*          serverSocket;
61    int                    type;
62    Header                 packetHeader;
63    bool                   bActive;
64    std::list<int>         freeSocketSlots;
65
66    int                    myHostId;
67    int                    maxConnections;
68
69    NetworkGameManager*   networkGameManager;
70
71    void updateConnectionList();
72};
73#endif /* _NETWORK_STREAM */
Note: See TracBrowser for help on using the repository browser.