TcpClient: replaced C style function parameters with std::function

Added initialization to config
Added receiving for UdpClient
Removed InitWindows.cpp
Laying foundation for PluginManager
This commit is contained in:
xX-TheDoctor-Xx
2016-10-31 14:05:03 +00:00
parent a9549c33e3
commit 91f80a6c58
11 changed files with 82 additions and 28 deletions

View File

@ -5,14 +5,20 @@
#pragma once
#endif
#include "Utility.hpp"
struct Config
{
static void Initialize();
static void SetUsingConsole(bool value);
static bool GetUsingConsole();
static void SetLogToFile(bool value);
static bool GetLogToFile();
static Utility::ConfigReader Configuration;
private:
static bool using_console;
static bool log_to_file;

13
include/PluginManager.hpp Normal file
View File

@ -0,0 +1,13 @@
#ifndef PLUGIN_MANAGER_HPP
#define PLUGIN_MANAGER_HPP
#ifdef _MSC_VER
#pragma once
#endif
struct PluginManager
{
};
#endif

View File

@ -45,9 +45,9 @@ struct TcpClient
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*));
void SetOnDisconnectCallback(std::function<void(uint16)> func);
void SetOnConnectCallback(std::function<void(uint16)> func);
void SetOnMessageCallback(std::function<void(uint16, byte, byte, void*)> func);
static const TcpClient &DefaultTcpClient();

View File

@ -31,11 +31,17 @@ struct UdpClient
uint16 GetID();
void SetID(uint16 id);
void ReceiveMessages();
const NetworkMessage &ReceiveMessage();
std::future<bool> SendMessage(const NetworkMessage &message);
bool SendBytes(const std::vector<byte> &bytes);
bool SendBytes(byte *bytes, uint32 lenght);
private:
const NetworkBuffer &receive_data_array();
static void receive_data(UdpClient *client);
bool initialize(const std::string &ip, uint16 port = default_client_port);
static bool send_network_message(const NetworkMessage &message, UdpClient *client);