Removed Tags file
Updated TODO file TcpClient: Added parameterless contructor, id is now -2 by default which is invalid, Added SendBytes method for C style arrays TcpServer: Added 2 CloseSocket function, one for TcpClient and another one for id, also added GetClientByID client is now declared on the stack in VoidNetClient Made Serializer code smaller, still need to integrate a compressor
This commit is contained in:
@ -185,4 +185,10 @@ enum ConnectionCode
|
||||
Reject
|
||||
};
|
||||
|
||||
enum InternalTags
|
||||
{
|
||||
CONNECT = 65534,
|
||||
DISCONNECT = 65535,
|
||||
};
|
||||
|
||||
#endif // DEFS_HPP
|
||||
@ -1,14 +0,0 @@
|
||||
#ifndef TAGS_HPP
|
||||
#define TAGS_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
enum InternalTags
|
||||
{
|
||||
CONNECT = 65534,
|
||||
DISCONNECT = 65535,
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -16,6 +16,7 @@
|
||||
class TcpClient
|
||||
{
|
||||
public:
|
||||
TcpClient();
|
||||
TcpClient(const SOCKET &socket);
|
||||
TcpClient(const std::string &ip);
|
||||
TcpClient(const std::string &ip, uint16 port = default_client_port);
|
||||
@ -43,6 +44,7 @@ public:
|
||||
const NetworkMessage &ReceiveMessage();
|
||||
void SendMessage(const NetworkMessage &message);
|
||||
void SendBytes(const std::vector<byte> &bytes);
|
||||
void SendBytes(byte *bytes, uint32 lenght);
|
||||
|
||||
void SetOnDisconnectCallback(void (*func)(uint16));
|
||||
void SetOnConnectCallback(void (*func)(uint16));
|
||||
@ -54,7 +56,7 @@ private:
|
||||
static void send_network_message(const NetworkMessage &message, TcpClient *client);
|
||||
bool initialize(const std::string &ip, uint16 port = default_client_port);
|
||||
|
||||
uint16 id = 0;
|
||||
uint16 id = -2;
|
||||
std::string ip;
|
||||
uint16 port = 0;
|
||||
bool initialized = false;
|
||||
|
||||
@ -32,6 +32,11 @@ public:
|
||||
void RejectConnection(TcpClient &client);
|
||||
void AcceptConnection(TcpClient &client);
|
||||
|
||||
void CloseSocket(TcpClient &client);
|
||||
void CloseSocket(uint16 id);
|
||||
|
||||
const TcpClient &GetClientByID(uint16 id);
|
||||
|
||||
std::function<void(const NetworkMessage &message)> OnMessage;
|
||||
|
||||
private:
|
||||
|
||||
@ -34,9 +34,8 @@ struct VoidNetClientAPI
|
||||
private:
|
||||
static void process_all_data();
|
||||
|
||||
static TcpClient *client;
|
||||
static TcpClient client;
|
||||
static uint16 id;
|
||||
static std::thread receive_thread;
|
||||
static bool receive;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user