Cafu Engine
NetDataT Class Reference

Class that allows easy and portable handling, sending and receiving of data over a network. More...

#include "Network.hpp"

Classes

struct  MessageLength
 Message length error. More...
 
struct  WinSockAPIError
 WinSock error. More...
 

Public Member Functions

 NetDataT ()
 Constructor. More...
 
void ReadBegin ()
 Initializes reading of the data buffer. More...
 
char ReadByte ()
 Reads one Byte (8 Bit) from the data buffer. More...
 
unsigned short ReadWord ()
 Read one Word (16 Bit) from the data buffer. More...
 
uint32_t ReadLong ()
 Reads one uint32_t from the data buffer. More...
 
float ReadFloat ()
 Reads one Float (32 Bit) from the data buffer. More...
 
const char * ReadString ()
 Reads a String from the data buffer. More...
 
ArrayT< uint8_t > ReadDMsg ()
 Reads a delta message for cf::Network::StateT from the data buffer. More...
 
void WriteByte (char b)
 Writes one Byte (8 Bit) into the data buffer. More...
 
void WriteWord (unsigned short w)
 Writes one Word (16 Bit) into the data buffer. More...
 
void WriteLong (uint32_t ui)
 Writes one uint32_t into the data buffer. More...
 
void WriteFloat (float f)
 Writes one float (32 Bit) into the data buffer. More...
 
void WriteString (const char *String)
 Writes a String into the data buffer. More...
 
void WriteString (const std::string &String)
 Writes a String into the data buffer. More...
 
void WriteArrayOfBytes (const ArrayT< char > &AoB)
 Writes an ArrayT<char> into the data buffer. More...
 
void WriteDMsg (const ArrayT< uint8_t > &DMsg)
 Writes a delta message as created by cf::Network::StateT into the data buffer. More...
 
void Send (SOCKET Socket, const NetAddressT &ReceiverAddress) const
 Send the content of NetDataT through 'Socket' (non-blocking UDP socket) to 'ReceiverAddress'. More...
 
NetAddressT Receive (SOCKET Socket)
 Receives one packet from 'Socket' (non-blocking UDP socket), overwrites the content of this NetDataT and returns the NetAddressT of the sender. More...
 

Public Attributes

ArrayT< char > Data
 Data buffer contents. More...
 
unsigned long ReadPos
 Reading position in data. More...
 
bool ReadOfl
 Whether the attempt was made to read over the data buffer boundaries. More...
 

Detailed Description

Class that allows easy and portable handling, sending and receiving of data over a network.

Constructor & Destructor Documentation

NetDataT::NetDataT ( )
inline

Constructor.

Member Function Documentation

void NetDataT::ReadBegin ( )
inline

Initializes reading of the data buffer.

char NetDataT::ReadByte ( )
inline

Reads one Byte (8 Bit) from the data buffer.

Returns
Byte read.
ArrayT<uint8_t> NetDataT::ReadDMsg ( )
inline

Reads a delta message for cf::Network::StateT from the data buffer.

Returns
Delta message read.
float NetDataT::ReadFloat ( )
inline

Reads one Float (32 Bit) from the data buffer.

Returns
Float value read.
uint32_t NetDataT::ReadLong ( )
inline

Reads one uint32_t from the data buffer.

Returns
The read unsigned integer.
const char* NetDataT::ReadString ( )
inline

Reads a String from the data buffer.

Returns
String read.
unsigned short NetDataT::ReadWord ( )
inline

Read one Word (16 Bit) from the data buffer.

Returns
Word read.
NetAddressT NetDataT::Receive ( SOCKET  Socket)

Receives one packet from 'Socket' (non-blocking UDP socket), overwrites the content of this NetDataT and returns the NetAddressT of the sender.

Parameters
SocketThe socket to receive the data from.
Exceptions
WinSockAPIError,whenreceicing failes.
void NetDataT::Send ( SOCKET  Socket,
const NetAddressT ReceiverAddress 
) const

Send the content of NetDataT through 'Socket' (non-blocking UDP socket) to 'ReceiverAddress'.

Parameters
SocketThe socket to send the data through.
ReceiverAddressThe address of the receiver.
Exceptions
WinSockAPIErrorif theres a WinSock API error
MessageLengthwhen the message was not completely sent.
void NetDataT::WriteArrayOfBytes ( const ArrayT< char > &  AoB)
inline

Writes an ArrayT<char> into the data buffer.

Parameters
AoBByte array to write.
void NetDataT::WriteByte ( char  b)
inline

Writes one Byte (8 Bit) into the data buffer.

Parameters
bByte to write.
void NetDataT::WriteDMsg ( const ArrayT< uint8_t > &  DMsg)
inline

Writes a delta message as created by cf::Network::StateT into the data buffer.

Parameters
DMsgDelta message to write.
void NetDataT::WriteFloat ( float  f)
inline

Writes one float (32 Bit) into the data buffer.

Parameters
fFloat to write.
void NetDataT::WriteLong ( uint32_t  ui)
inline

Writes one uint32_t into the data buffer.

Parameters
uiThe 32-bit unsigned integer to write.
void NetDataT::WriteString ( const char *  String)
inline

Writes a String into the data buffer.

Parameters
StringString to write.
void NetDataT::WriteString ( const std::string &  String)
inline

Writes a String into the data buffer.

Parameters
StringString to write.
void NetDataT::WriteWord ( unsigned short  w)
inline

Writes one Word (16 Bit) into the data buffer.

Parameters
wWord to write.

Member Data Documentation

ArrayT<char> NetDataT::Data

Data buffer contents.

bool NetDataT::ReadOfl

Whether the attempt was made to read over the data buffer boundaries.

unsigned long NetDataT::ReadPos

Reading position in data.


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