Updated TODO list
Removed windows specific files since the code is the same for linux UdpClient: added basic methods to interact with the variables of that class, added initialization and started with sending and receiving messages UdpServer: added initialization and basic variables Utility: added a bunch of methods to the StringConverter utility class VoidNetClientAPI: SendMessage now checks if message is not an handshake
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
@ -39,18 +40,24 @@ struct TcpClient
|
||||
|
||||
//this is a more manual method with no callbacks
|
||||
const NetworkMessage &ReceiveMessage();
|
||||
void SendMessage(const NetworkMessage &message);
|
||||
void SendBytes(const std::vector<byte> &bytes);
|
||||
void SendBytes(byte *bytes, uint32 lenght);
|
||||
|
||||
std::future<bool> SendMessage(const NetworkMessage &message);
|
||||
bool SendBytes(const std::vector<byte> &bytes);
|
||||
bool SendBytes(byte *bytes, uint32 lenght);
|
||||
|
||||
void SetOnDisconnectCallback(void (*func)(uint16));
|
||||
void SetOnConnectCallback(void (*func)(uint16));
|
||||
void SetOnMessageCallback(void (*func)(uint16, byte, byte, void*));
|
||||
|
||||
static const TcpClient &DefaultTcpClient();
|
||||
|
||||
private:
|
||||
TcpClient();
|
||||
|
||||
const NetworkBuffer &receive_data_array();
|
||||
static void receive_data(TcpClient *client);
|
||||
static void send_network_message(const NetworkMessage &message, TcpClient *client);
|
||||
static bool send_network_message(const NetworkMessage &message, TcpClient *client);
|
||||
|
||||
bool initialize(const std::string &ip, uint16 port = default_client_port);
|
||||
|
||||
uint16 id = -2;
|
||||
@ -63,11 +70,9 @@ private:
|
||||
std::function<void(uint16)> OnConnect;
|
||||
std::function<void(uint16, byte, byte, void*)> OnMessage;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
SOCKET tcp_socket = INVALID_SOCKET;
|
||||
struct addrinfo *result = nullptr;
|
||||
struct addrinfo hints;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user