Added a bunch of undefs to Defs.hpp
Hanshake now has distribution_mode Removed all the undef SendMessage and redefenitions, we are undefing it in Defs.hpp and we are now defing it back Added SendHanshake GetMaxConnections SetMaxConnections and shutdown_internal methods in TcpServer.hpp and changed AcceptConnection parameter to uint16 Removed process_all_data method in VoidNetClient.hpp Placed some functions that are OS independent in main cpp files to prevent the DRY concept Fixed receive_data_array method in TcpClientWindows.cpp VoidNetClientAPI::SendMessage now checks if tags dont have the CONNECT or DISCONNECT value because thats reserved to the server
This commit is contained in:
@ -3,8 +3,6 @@
|
||||
|
||||
#include <future>
|
||||
|
||||
#undef SendMessage
|
||||
|
||||
bool VoidNetClientAPI::Connect(const std::string &ip, uint16 port)
|
||||
{
|
||||
client.SetIP(ip);
|
||||
@ -39,27 +37,26 @@ void VoidNetClientAPI::SendMessageToAllAndMe(byte tag, byte subject, void *data)
|
||||
|
||||
void VoidNetClientAPI::SendMessage(byte distribution_mode, uint16 destination_id, byte tag, byte subject, void *data)
|
||||
{
|
||||
NetworkMessage message;
|
||||
message.tag = tag;
|
||||
message.subject = subject;
|
||||
message.data = data;
|
||||
message.distribution_mode = distribution_mode;
|
||||
message.sender = id;
|
||||
message.destination_id = destination_id;
|
||||
client.SendMessage(message);
|
||||
if (tag != CONNECT && tag != DISCONNECT)
|
||||
{
|
||||
NetworkMessage message;
|
||||
message.tag = tag;
|
||||
message.subject = subject;
|
||||
message.data = data;
|
||||
message.distribution_mode = distribution_mode;
|
||||
message.sender = id;
|
||||
message.destination_id = destination_id;
|
||||
client.SendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
void VoidNetClientAPI::Receive()
|
||||
{
|
||||
std::async(std::launch::async, &process_all_data);
|
||||
}
|
||||
|
||||
void VoidNetClientAPI::process_all_data()
|
||||
{
|
||||
client.ReceiveMessages();
|
||||
std::async(std::launch::async, &client.ReceiveMessages);
|
||||
}
|
||||
|
||||
void VoidNetClientAPI::Disconnect()
|
||||
{
|
||||
receive = false;
|
||||
SendMessageToServer
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user