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:
xX-TheDoctor-Xx
2016-07-17 19:59:22 +01:00
parent 16ed3619b3
commit 72aa8ee0c4
11 changed files with 56 additions and 22 deletions

View File

@ -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

View File

@ -12,7 +12,7 @@ struct NetworkBuffer
NetworkBuffer();
~NetworkBuffer();
int body_size;
uint32 body_size;
byte *body = nullptr;
};

View File

@ -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;
};

View File

@ -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

View File

@ -25,7 +25,7 @@ public:
VoidCode Connect();
char *ReceiveDataArray();
NetworkBuffer ReceiveDataArray();
const NetworkMessage &ReceiveData();
bool SendData(const NetworkMessage &message);