|
|
|
|
@ -15,12 +15,48 @@ static void Sleep(unsigned int milliseconds)
|
|
|
|
|
|
|
|
|
|
NetworkClient::NetworkClient(std::vector<RGBController *>& control) : controllers(control)
|
|
|
|
|
{
|
|
|
|
|
strcpy(port_ip, "127.0.0.1");
|
|
|
|
|
port_num = 1337;
|
|
|
|
|
server_connected = false;
|
|
|
|
|
server_controller_count = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned short NetworkClient::GetPort()
|
|
|
|
|
{
|
|
|
|
|
return port_num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NetworkClient::GetOnline()
|
|
|
|
|
{
|
|
|
|
|
return server_connected;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetworkClient::SetIP(const char *new_ip)
|
|
|
|
|
{
|
|
|
|
|
if(server_connected == false)
|
|
|
|
|
{
|
|
|
|
|
strcpy(port_ip, new_ip);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetworkClient::SetPort(unsigned short new_port)
|
|
|
|
|
{
|
|
|
|
|
if(server_connected == false)
|
|
|
|
|
{
|
|
|
|
|
port_num = new_port;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetworkClient::StartClient()
|
|
|
|
|
{
|
|
|
|
|
unsigned int requested_controllers;
|
|
|
|
|
|
|
|
|
|
port.tcp_client("127.0.0.1", "1337");
|
|
|
|
|
//Start a TCP server and launch threads
|
|
|
|
|
char port_str[6];
|
|
|
|
|
snprintf(port_str, 6, "%d", port_num);
|
|
|
|
|
|
|
|
|
|
port.tcp_client(port_ip, port_str);
|
|
|
|
|
|
|
|
|
|
server_connected = false;
|
|
|
|
|
server_controller_count = 0;
|
|
|
|
|
requested_controllers = 0;
|
|
|
|
|
|
|
|
|
|
//Start the connection thread
|
|
|
|
|
@ -70,6 +106,11 @@ NetworkClient::NetworkClient(std::vector<RGBController *>& control) : controller
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetworkClient::StopClient()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NetworkClient::ConnectionThreadFunction()
|
|
|
|
|
{
|
|
|
|
|
//This thread manages the connection to the server
|
|
|
|
|
|