Files
VoidNet/include/VoidNetClient.hpp
xX-TheDoctor-Xx 81a065b98b 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
2016-08-01 14:22:59 +01:00

49 lines
1.1 KiB
C++

#ifndef VOID_NET_HPP
#define VOID_NET_HPP
#ifdef _MSC_VER
#pragma once
#endif
#include "Defs.hpp"
#include "Init.hpp"
#include "TcpClient.hpp"
#include "NetworkBuffer.hpp"
#include "NetworkMessage.hpp"
#include <string>
#include <thread>
#undef SendMessage
struct VoidNetClientAPI
{
static bool Connect(const std::string &ip, uint16 port = default_client_port);
static void Disconnect();
static void SendMessageToServer(byte tag, byte subject, void *data);
static void SendMessageToID(uint16 id, byte tag, byte subject, void *data);
static void SendMessageToOthers(byte tag, byte subject, void *data);
static void SendMessageToAll(byte tag, byte subject, void *data);
static void SendMessageToAllAndMe(byte tag, byte subject, void *data);
static void SendMessage(byte distribution_mode, uint16 destination_id, byte tag, byte subject, void *data);
static void Receive();
private:
static void process_all_data();
static TcpClient client;
static uint16 id;
static bool receive;
};
#ifdef UNICODE
#define SendMessage SendMessageW
#else
#define SendMessage SendMessageA
#endif // !UNICODE
#endif