Got tcp receiving for windows done
Callbacks are done - maybe ill add a few more later - i dont know if they will work correctly yet Fixed the Serialization class Added internal tags - for now it only has CONNECT and DISCONNECT - maybe ill add more later Fixed some data type parameters in some functions
This commit is contained in:
@ -8,10 +8,10 @@
|
||||
#include "Defs.hpp"
|
||||
#include "Serializer.hpp"
|
||||
|
||||
void OnMessage(byte sender, byte tag, uint16 subject, byte *data);
|
||||
void OnMessage(uint16 sender, uint16 tag, uint16 subject, void *data);
|
||||
|
||||
void OnDisconnect(byte id);
|
||||
void OnDisconnect(uint16 id);
|
||||
|
||||
void OnConnect(byte id);
|
||||
void OnConnect(uint16 id);
|
||||
|
||||
#endif
|
||||
@ -12,7 +12,7 @@ struct NetworkBuffer
|
||||
NetworkBuffer();
|
||||
~NetworkBuffer();
|
||||
|
||||
int body_size;
|
||||
uint32 body_size;
|
||||
byte *body = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
struct NetworkMessage
|
||||
{
|
||||
NetworkMessage();
|
||||
NetworkMessage(const NetworkBuffer &buffer);
|
||||
NetworkMessage(uint16 sender, byte distribution_mode, uint16 destination_id, byte tag, uint16 subject, NetworkBuffer buffer);
|
||||
~NetworkMessage();
|
||||
|
||||
@ -25,9 +26,9 @@ struct NetworkMessage
|
||||
byte distribution_mode;
|
||||
uint16 tag;
|
||||
uint16 subject;
|
||||
|
||||
void *data;
|
||||
|
||||
private:
|
||||
NetworkBuffer buffer;
|
||||
};
|
||||
|
||||
|
||||
@ -7,12 +7,10 @@
|
||||
|
||||
#include "Defs.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
class Serializer
|
||||
struct Serializer
|
||||
{
|
||||
template<typename T> std::array<byte, sizeof(T)> to_bytes(const T& object);
|
||||
template<typename T> T& from_bytes(const std::array<byte, sizeof(T)> &bytes, T& object);
|
||||
template<typename T> static const std::vector<byte> &to_bytes(const T &object);
|
||||
template<typename T> static const T &from_bytes(byte *bytes, T &object);
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -25,7 +25,7 @@ public:
|
||||
|
||||
VoidCode Connect();
|
||||
|
||||
char *ReceiveDataArray();
|
||||
NetworkBuffer ReceiveDataArray();
|
||||
const NetworkMessage &ReceiveData();
|
||||
bool SendData(const NetworkMessage &message);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user