Added a new type: longlong
TcpClient and TcpServer are now structs intead of classes Starting with UdpClient Added 2 new methods to StringConverter: Split and Trim ConfigReader: Changed ReadNodes return type to void, parameter of operator [] is now a std::string Starting with the VoidNetServer class which is an all in one for Tcp and Udp Finally implemented the methods for the ConfigReader
This commit is contained in:
@ -13,8 +13,6 @@ struct Config
|
||||
static void SetLogToFile(bool value);
|
||||
static bool GetLogToFile();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
static bool using_console;
|
||||
static bool log_to_file;
|
||||
|
||||
@ -216,6 +216,8 @@ typedef unsigned long long uint64;
|
||||
|
||||
#endif // compiler data type defenitions
|
||||
|
||||
typedef long long longlong;
|
||||
|
||||
const uint16 default_client_port = 60250;
|
||||
const uint16 default_server_port = 61250;
|
||||
|
||||
|
||||
@ -12,9 +12,8 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class TcpClient
|
||||
struct TcpClient
|
||||
{
|
||||
public:
|
||||
TcpClient();
|
||||
TcpClient(const SOCKET &socket);
|
||||
TcpClient(const std::string &ip);
|
||||
|
||||
@ -11,9 +11,8 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
class TcpServer
|
||||
struct TcpServer
|
||||
{
|
||||
public:
|
||||
TcpServer();
|
||||
TcpServer(uint16 port = default_server_port);
|
||||
~TcpServer();
|
||||
|
||||
13
include/UdpClient.hpp
Normal file
13
include/UdpClient.hpp
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef UDP_CLIENT_HPP
|
||||
#define UDP_CLIENT_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
struct UdpClient
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -57,14 +57,17 @@ struct Utility
|
||||
static const std::string &ToString(const std::vector<byte> &bytes);
|
||||
|
||||
static const std::string &ToString(const std::vector<byte> &bytes, uint16 start_index = 0, uint16 lenght = 0);
|
||||
|
||||
static const std::string &Trim(std::string &str, char ch);
|
||||
static std::vector<std::string> Split(const std::string &str, const std::string &delimiter);
|
||||
};
|
||||
|
||||
struct ConfigReader
|
||||
{
|
||||
void ReadConfig(const std::string &file_name);
|
||||
const std::map<std::string, std::string> &ReadNodes();
|
||||
void ReadNodes();
|
||||
|
||||
const std::string &operator[](uint16 index);
|
||||
const std::string &operator[](const std::string &key);
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> nodes;
|
||||
|
||||
@ -32,7 +32,7 @@ struct VoidNetClientAPI
|
||||
private:
|
||||
static void receive_data();
|
||||
|
||||
static TcpClient client;
|
||||
static TcpClient tcp_client;
|
||||
static uint16 id;
|
||||
};
|
||||
|
||||
|
||||
@ -5,4 +5,12 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "TcpServer.hpp"
|
||||
|
||||
struct VoidNetServer
|
||||
{
|
||||
private:
|
||||
TcpServer server;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user