Last change
on this file since 5829 was
5829,
checked in by patrick, 19 years ago
|
network: much work on multiplayability, does not yet work
|
File size:
1.5 KB
|
Rev | Line | |
---|
[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 | |
---|
[5582] | 9 | #include "data_stream.h" |
---|
[5809] | 10 | #include "network_protocol.h" |
---|
[5566] | 11 | |
---|
[5647] | 12 | class Synchronizeable; |
---|
| 13 | class NetworkSocket; |
---|
| 14 | class ConnectionMonitor; |
---|
[5741] | 15 | class NetworkProtocol; |
---|
[5589] | 16 | |
---|
[5809] | 17 | |
---|
| 18 | //<! The state of the NetworkStream |
---|
| 19 | typedef enum NetStat { |
---|
| 20 | NET_REC_HEADER = 0, //!< Waiting for header |
---|
| 21 | NET_REC_DATA, //!< Waiting for data |
---|
| 22 | |
---|
| 23 | NUM_STATES //!< Number of states |
---|
| 24 | }; |
---|
| 25 | |
---|
| 26 | |
---|
[5649] | 27 | class NetworkStream : public DataStream |
---|
[5566] | 28 | { |
---|
| 29 | |
---|
[5829] | 30 | public: |
---|
| 31 | NetworkStream(); |
---|
| 32 | NetworkStream(IPaddress& address, NodeType type); |
---|
| 33 | NetworkStream(unsigned int port, NodeType type); |
---|
[5804] | 34 | |
---|
[5829] | 35 | NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type); |
---|
| 36 | NetworkStream(unsigned int port, Synchronizeable& sync, NodeType type); |
---|
| 37 | ~NetworkStream(); |
---|
| 38 | void init(); |
---|
[5804] | 39 | |
---|
[5829] | 40 | void connectSynchronizeable(Synchronizeable& sync); |
---|
[5566] | 41 | |
---|
[5829] | 42 | inline bool isServer() const { return (this->type == NET_SERVER)? true:false; } |
---|
| 43 | inline bool isActive() const { return this->bActive; } |
---|
| 44 | |
---|
| 45 | virtual void processData(); |
---|
| 46 | |
---|
| 47 | private: |
---|
| 48 | NetworkProtocol* networkProtocol; |
---|
| 49 | ConnectionMonitor* connectionMonitor; |
---|
| 50 | Synchronizeable* synchronizeables; |
---|
| 51 | NetworkSocket* networkSocket; |
---|
| 52 | int type; |
---|
| 53 | int state; |
---|
| 54 | Header packetHeader; |
---|
| 55 | bool bActive; |
---|
[5587] | 56 | }; |
---|
[5566] | 57 | #endif /* _NETWORK_STREAM */ |
---|
Note: See
TracBrowser
for help on using the repository browser.