Cafu Engine
GameProtocol1T Class Reference

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 NetDataTGetTransmitData (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 NetDataTGetTransmitOutOfBandData (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...
 

Detailed Description

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).

Constructor & Destructor Documentation

GameProtocol1T::GameProtocol1T ( )

Create a connection over the GameProtocol1T.

Member Function Documentation

unsigned long GameProtocol1T::GetNextOutgoingSequenceNr ( )
inline

Returns the sequence number of the next packet sent to the remote client that is not-out-of-band.

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.

Parameters
ReliableDatasReliable data parts from which the NetDataT is build.
UnreliableDataUnreliable data from which the NetDataT is build.
Returns
NetDataT object ready to send over the network.
const NetDataT & GameProtocol1T::GetTransmitOutOfBandData ( const ArrayT< char > &  UnreliableData)
static

Returns NetDataT with 'UnreliableData' as 'out-of-band' message.

NetData can then be sent to the protocol remote client.

Parameters
UnreliableDataThe unrelilable data to create a NetDataT object from.
Returns
The NetDataT object created from UnreliableData.
bool GameProtocol1T::IsIncomingMessageOutOfBand ( NetDataT InData)
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.

Parameters
InDataNetDataT to check.
Returns
True if InData is a 'out-of-band' message, false otherwise.
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).

Parameters
InDataThe data received from a remote client.
ProcessPayloadThe function used to process the payload.
Returns
The last SequenceNr that the remote client has seen from us (RemoteLastIncomingSequenceNr)

The documentation for this class was generated from the following files: