| 1 | = NetworkProtocol = |
| 2 | |
| 3 | Short description of the module and its functions: |
| 4 | |
| 5 | Next steps: |
| 6 | * remove Version Nr Entry |
| 7 | * merge senderID and receiverID -> synchronizeableID |
| 8 | |
| 9 | |
| 10 | Network Header: |
| 11 | |
| 12 | || 1 byte || 1 byte || |
| 13 | || synchronizeableID || Payload length || |
| 14 | |
| 15 | [[br]] |
| 16 | [[br]] |
| 17 | |
| 18 | {{{ |
| 19 | /* general notes: |
| 20 | - The network protocol creates and reads the header of a network packet. |
| 21 | */ |
| 22 | |
| 23 | /* public functions */ |
| 24 | public: |
| 25 | |
| 26 | /* |
| 27 | * This constructor creates a new DataStream and connects it to both streams (upStream, downStream) |
| 28 | */ |
| 29 | NetworkProtocol(); |
| 30 | |
| 31 | /* |
| 32 | * creates a new packet header from the function arguments |
| 33 | * |
| 34 | * @arg data: the binary data without header -> return the data in this binary array |
| 35 | * @arg length: the data length without header |
| 36 | * @arg bufferLength: the length of the internal buffer |
| 37 | * @arg source: reference to the source Synchronizeable object |
| 38 | * @arg remoteID: id number of the remote Synchronizeable object |
| 39 | * @return: the new data length with header (the header data is included into byte* data) |
| 40 | */ |
| 41 | int createHeader(byte* data, int length, int bufferLength, const Synchronizeable& source, unsigned int remoteID); |
| 42 | |
| 43 | |
| 44 | /* |
| 45 | * remove the header from the binary data stream and returns a pointer to the |
| 46 | * destination object |
| 47 | */ |
| 48 | Synchronizeable& removeHeader(byte* data, int length); |
| 49 | |
| 50 | }}} |