Packet

Utility class to build blocks of data to transfer over the network.

Packets provide a safe and easy way to serialize data, in order to send it over the network using sockets (sf::TcpSocket, sf::UdpSocket).

Constructors

this
this()

Default constructor

Destructor

~this
~this()

Destructor

Members

Functions

append
void append(const(void)[] data)

Append data to the end of the packet.

clear
void clear()

Clear the packet.

endOfPacket
bool endOfPacket()

Tell if the reading position has reached the end of the packet.

getData
const(void)[] getData()

Get a slice of the data contained in the packet.

onRecieve
void onRecieve(const(void)[] data)

Called after the packet is received over the network.

onSend
const(void)[] onSend()

Called before the packet is sent over the network.

read
bool read(T value)

Reads a primitive data type or string from the packet. The value in the packet at the current read position is set to value.

write
void write(T value)

Writes a scalar data type or string to the packet.

Meta