| 1 | = NetworkStream = |
| 2 | |
| 3 | Next steps: |
| 4 | * Object creation and destruciton: |
| 5 | 1. The NetworkStream creates a NetworkSocket in its constructor |
| 6 | 1. The NetworkStream deletes and uninitializes the NetworkSocket in its constructor |
| 7 | * processData() function: upstream |
| 8 | 1. it first gets the data from the underlaying NetworkSocket. |
| 9 | 1. pass the data to the ConnectionMonitor::processData(); |
| 10 | 1. pass the data to the NetworkProtocol::removeHeader(); |
| 11 | 1. pass the data to the [wiki:Synchronizeable Synchronizeable] object |
| 12 | * processData() function: downstream |
| 13 | 1. get the data from the [wiki:Synchronizeable Synchronizeable] object |
| 14 | 1. pass the data to the ConnectionMonitor::processData(); |
| 15 | 1. pass the data to the NetworkProtocol::removeHeader(); |
| 16 | 1. pass the data to the NetworkSocket object |
| 17 | * test your work always with the src/subprojects/network/ application |
| 18 | |
| 19 | [[br]] |
| 20 | [[br]] |
| 21 | |
| 22 | {{{ |
| 23 | |
| 24 | /* public: */ |
| 25 | |
| 26 | /* |
| 27 | * Standard constructor for testing purposes |
| 28 | */ |
| 29 | NetworkStream(); |
| 30 | |
| 31 | /* |
| 32 | * Constructor for the network stream that is called from the NetworkManager. The constructor |
| 33 | * will generate the NetworkSocket from the IPaddress informations. |
| 34 | * |
| 35 | * @param address: the address informations (SDL_net.h definition) of the remote host |
| 36 | * @param sync: the synchronizeable object, the other end of the connection |
| 37 | * @param type: the node type: Client/Server |
| 38 | */ |
| 39 | NetworkStream(IPaddress& address, const Synchronizeable& sync, NodeType type); |
| 40 | |
| 41 | |
| 42 | /* |
| 43 | * Constructor for the network stream that is called from the NetworkManager |
| 44 | * |
| 45 | * @param sync: the synchronizeable object, the other end of the connection |
| 46 | * @param type: the node type: Client/Server |
| 47 | */ |
| 48 | NetworkStream(const Synchronizeable& sync, NodeType type); |
| 49 | |
| 50 | |
| 51 | |
| 52 | /* |
| 53 | * Passes the data from the Network socket to the synchronizeable socket and vice versa (take a look |
| 54 | * at the UML Sequenca Graph). At the end of the transaction, the ConnectionMonitor will be kicked on. |
| 55 | */ |
| 56 | void processData(); |
| 57 | |
| 58 | /* protected: */ |
| 59 | |
| 60 | /* |
| 61 | * Is invoked by the processData() function and passes the data from the synchronizeable object to the |
| 62 | * NetworkSocket. |
| 63 | * This function is an implementation of the virtual void DataStream::passDown(byte* data, int length) function. |
| 64 | * |
| 65 | * 1. get the data from the Synchronizeable object by calling: Synchronizeable::readBytes(byte* data) |
| 66 | * 2. save the data locally |
| 67 | * 3. pass the data to the NetworkSocket by calling NetworkSocket::writeBytes(byte* data, int length) |
| 68 | */ |
| 69 | virtual void passDown(byte* data, int length); |
| 70 | |
| 71 | /* |
| 72 | * Is invoked by the processData() function and passes the data from the NetworkSocket to the |
| 73 | * synchronizeable object |
| 74 | * This function is an implementation of the virtual int DataStream::passUp(byte* data) function |
| 75 | * |
| 76 | * 1. get the data from the NetworkSocket object by calling: NetworkSocket::readBytes(byte* data) |
| 77 | * 2. save the data locally |
| 78 | * 3. pass the data to the Synchronizeable object calling the |
| 79 | * Synchronizeable::writeBytes(byte* data, int length); |
| 80 | */ |
| 81 | virtual int passUp(byte* data); |
| 82 | |
| 83 | }}} |