Packet.h 969 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef PACKET_H
  2. #define PACKET_H
  3. #include "network/ENet.h"
  4. #include "utils/Types.h"
  5. class InPacket {
  6. ENetPacket* packet;
  7. unsigned int index;
  8. friend class Server;
  9. InPacket(ENetPacket* packet);
  10. bool read(void* buffer, unsigned int length);
  11. public:
  12. bool readU8(uint8& u);
  13. bool readU16(uint16& u);
  14. bool readU32(uint32& u);
  15. bool readS8(int8& u);
  16. bool readS16(int16& u);
  17. bool readS32(int32& u);
  18. };
  19. class OutPacket {
  20. ENetPacket* packet;
  21. unsigned int index;
  22. friend class Client;
  23. public:
  24. OutPacket(unsigned int size, int flags);
  25. ~OutPacket();
  26. OutPacket(const OutPacket& other);
  27. OutPacket(OutPacket&& other);
  28. OutPacket& operator=(OutPacket other);
  29. void writeU8(uint8 u);
  30. void writeU16(uint16 u);
  31. void writeU32(uint32 u);
  32. void writeS8(int8 s);
  33. void writeS16(int16 s);
  34. void writeS32(int32 s);
  35. private:
  36. void write(const void* buffer, unsigned int length);
  37. };
  38. #endif