This class implements a mixture of a reliable and unreliable, bi-directional network protocol for Cafu. More...
#include "Network.hpp"
Classes | |
struct | MaxMsgSizeExceeded |
The exception that might be thrown on failure of the GetTransmitData() method. More... | |
Public Member Functions | |
GameProtocol1T () | |
Create a connection over the GameProtocol1T. More... | |
const NetDataT & | GetTransmitData (const ArrayT< ArrayT< char > > &ReliableDatas, const ArrayT< char > &UnreliableData) |
This function takes 'ReliableDatas' and 'UnreliableData' and returns a 'NetDataT' object created from them that can be sent to the address of the protocol remote client. More... | |
unsigned long | ProcessIncomingMessage (NetDataT &InData, void(*ProcessPayload)(NetDataT &, unsigned long)) |
Passes the data ('Payload') that has been received from our protocol remote client to ProcessPayload() for evaluation. More... | |
unsigned long | GetNextOutgoingSequenceNr () |
Returns the sequence number of the next packet sent to the remote client that is not-out-of-band. More... | |
Static Public Member Functions | |
static const NetDataT & | GetTransmitOutOfBandData (const ArrayT< char > &UnreliableData) |
Returns NetDataT with 'UnreliableData' as 'out-of-band' message. More... | |
static bool | IsIncomingMessageOutOfBand (NetDataT &InData) |
Returns true if 'InData' is a 'out-of-band' message, 'false' otherwise. More... | |
This class implements a mixture of a reliable and unreliable, bi-directional network protocol for Cafu.
Focus is on delivering unreliable messages fast and reliable messages reliable (excatly once and in order).
GameProtocol1T::GameProtocol1T | ( | ) |
Create a connection over the GameProtocol1T.
|
inline |
Returns the sequence number of the next packet sent to the remote client that is not-out-of-band.
const NetDataT & GameProtocol1T::GetTransmitData | ( | const ArrayT< ArrayT< char > > & | ReliableDatas, |
const ArrayT< char > & | UnreliableData | ||
) |
This function takes 'ReliableDatas' and 'UnreliableData' and returns a 'NetDataT' object created from them that can be sent to the address of the protocol remote client.
Note: 'ReliableDatas' is an array of arrays by intention. Its elements, e.g. 'ReliableDatas[i]', should consists of small self contained "reliable messages". This is necessary so the function has a clue where to cut the complete message. Examples: a) The sum of the data in 'ReliableDatas' is to great for a single network packet, but each component ('ReliableDatas[i]') is small enough. b) Because of network problems more and more "reliable messages" are jammed. In both cases this function takes as many data from the queue as possible at the borders of whole 'ReliableDatas[i]'. The ONLY failure case (exception 'MaxMsgSizeExceeded') occurs if any 'ReliableDatas[i]' exceeds the maximal possible network packet size. This should NEVER happen.
ReliableDatas | Reliable data parts from which the NetDataT is build. |
UnreliableData | Unreliable data from which the NetDataT is build. |
|
static |
Returns true if 'InData' is a 'out-of-band' message, 'false' otherwise.
If 'true', 'InData' is changed in a way that after this call the payload can be read directly.
InData | NetDataT to check. |
unsigned long GameProtocol1T::ProcessIncomingMessage | ( | NetDataT & | InData, |
void(*)(NetDataT &, unsigned long) | ProcessPayload | ||
) |
Passes the data ('Payload') that has been received from our protocol remote client to ProcessPayload() for evaluation.
If an error occurs (e.g. InData not usable because obsolete) 0 is returned. Otherwise the return value is the last SequenceNr that the remote client has seen from us (RemoteLastIncomingSequenceNr).
InData | The data received from a remote client. |
ProcessPayload | The function used to process the payload. |