25#ifndef SFML_PACKET_HPP
26#define SFML_PACKET_HPP
50 typedef bool (
Packet::*BoolType)(std::size_t);
77 void append(
const void* data, std::size_t sizeInBytes);
171 operator BoolType()
const;
358 virtual const void*
onSend(std::size_t& size);
377 virtual void onReceive(
const void* data, std::size_t size);
398 bool checkSize(std::size_t size);
403 std::vector<char> m_data;
404 std::size_t m_readPos;
405 std::size_t m_sendPos;
Utility class to build blocks of data to transfer over the network.
std::size_t getDataSize() const
Get the size of the data contained in the packet.
void clear()
Clear the packet.
bool endOfPacket() const
Tell if the reading position has reached the end of the packet.
Packet()
Default constructor.
void append(const void *data, std::size_t sizeInBytes)
Append data to the end of the packet.
const void * getData() const
Get a pointer to the data contained in the packet.
virtual void onReceive(const void *data, std::size_t size)
Called after the packet is received over the network.
virtual ~Packet()
Virtual destructor.
virtual const void * onSend(std::size_t &size)
Called before the packet is sent over the network.
Utility string class that automatically handles conversions between types and encodings.
Specialized socket using the TCP protocol.
Specialized socket using the UDP protocol.
SFML_NETWORK_API std::istream & operator>>(std::istream &stream, IpAddress &address)
Overload of >> operator to extract an IP address from an input stream.
SFML_NETWORK_API bool operator==(const IpAddress &left, const IpAddress &right)
Overload of == operator to compare two IP addresses.
SFML_NETWORK_API bool operator!=(const IpAddress &left, const IpAddress &right)
Overload of != operator to compare two IP addresses.
unsigned long long Uint64
SFML_NETWORK_API std::ostream & operator<<(std::ostream &stream, const IpAddress &address)
Overload of << operator to print an IP address to an output stream.