New configuration variable, log_to_file
Shutdown function added to TcpClient Shutdown function added to TcpServer Renamed socket to server_tcp_socket in TcpServer Implemented ConfigReader class
This commit is contained in:
@ -10,8 +10,14 @@ struct Config
|
||||
static void SetUsingConsole(bool value);
|
||||
static bool GetUsingConsole();
|
||||
|
||||
static void SetLogToFile(bool value);
|
||||
static bool GetLogToFile();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
static bool using_console;
|
||||
static bool log_to_file;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -21,6 +21,8 @@ public:
|
||||
TcpClient(const std::string &ip, uint16 port = default_client_port);
|
||||
~TcpClient();
|
||||
|
||||
void Shutdown();
|
||||
|
||||
const std::string &GetIP();
|
||||
void SetIP(const std::string &ip);
|
||||
|
||||
|
||||
@ -21,6 +21,8 @@ public:
|
||||
TcpServer(uint16 port = default_server_port);
|
||||
~TcpServer();
|
||||
|
||||
void Shutdown();
|
||||
|
||||
uint16 AllocateID();
|
||||
void AddToClientsList(const TcpClient &client);
|
||||
bool StartServer(bool accept_connections);
|
||||
@ -45,7 +47,7 @@ private:
|
||||
std::vector<TcpClient> clients;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
SOCKET socket = INVALID_SOCKET;
|
||||
SOCKET server_tcp_socket = INVALID_SOCKET;
|
||||
struct addrinfo *result = nullptr;
|
||||
struct addrinfo hints;
|
||||
#endif
|
||||
|
||||
@ -8,8 +8,7 @@
|
||||
#include "Defs.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <streambuf>
|
||||
#include <istream>
|
||||
#include <map>
|
||||
|
||||
struct Utility
|
||||
{
|
||||
@ -57,6 +56,18 @@ struct Utility
|
||||
|
||||
static const std::string &ToString(byte *bytes, uint16 start_index = 0, uint16 lenght = 0);
|
||||
};
|
||||
|
||||
struct ConfigReader
|
||||
{
|
||||
const void ReadConfig(const std::string &file_name);
|
||||
const std::map<std::string, std::string> &ReadNodes();
|
||||
|
||||
const std::string &operator[](uint16 index);
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> nodes;
|
||||
std::string file_content;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user