Added Tests project, Callback functions are in progress, NetworkBuffer is done, Network Message is WIP but already has a lot of code, Serializer is done (subject to change), Utility classes are being made, and TcpClientWindows is WIP.

Every single piece of code wrote today may or not change, but it will probably change because ill find a better way to do it xD
This commit is contained in:
xX-TheDoctor-Xx
2016-07-17 02:46:42 +01:00
parent 97262ee8c6
commit 16ed3619b3
37 changed files with 483 additions and 45 deletions

View File

@ -1,6 +1,7 @@
#include "TcpClient.hpp"
#include "Utility.hpp"
#include "Config.hpp"
#include "NetworkBuffer.hpp"
#include <iostream>
@ -57,21 +58,21 @@ TcpClient::~TcpClient()
Utility::Delete(ptr);
}
const std::string & TcpClient::GetIP()
const std::string &TcpClient::GetIP()
{
return ip;
}
void TcpClient::SetIP(const std::string & ip)
{
this->ip = ip;
}
uint16 TcpClient::GetPort()
{
return port;
}
void TcpClient::SetIP(const std::string & ip)
{
this->ip = ip;
}
void TcpClient::SetPort(uint16 port)
{
this->port = port;
@ -96,19 +97,20 @@ VoidCode TcpClient::Connect()
char *TcpClient::ReceiveDataArray()
{
char *header = new char[4]();
int remote_buffer_size;
do
{
remote_buffer_size = recv(socket, header, 4, 0);
NetworkBuffer buffer;
if (WSAGetLastError() != 0)
{
// there was a problem receiving
}
}
while (remote_buffer_size > 0);
if (recv(socket, reinterpret_cast<char*>(buffer.body_size), 4, 0) != 4 || WSAGetLastError() != 0)
{
// there was a problem receiving the body size of the message
return nullptr;
}
buffer.body = new byte[buffer.body_size]();
if (recv(socket, reinterpret_cast<char*>(buffer.body), buffer.body_size, 0) != buffer.body_size || WSAGetLastError() != 0)
{
//there was a problem receiving the body of the message
return nullptr;
}
}
const NetworkMessage &TcpClient::ReceiveData()