Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged the network branche back to the trunk, so we do not get away from each other to fast

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