|
@@ -25,13 +25,13 @@ ConsoleServer::ConsoleServer(uint16_t port, bool wait)
|
|
|
|
|
|
|
|
if (wait)
|
|
if (wait)
|
|
|
{
|
|
{
|
|
|
- AcceptResult result;
|
|
|
|
|
|
|
+ AcceptResult ar;
|
|
|
TCPSocket client;
|
|
TCPSocket client;
|
|
|
do
|
|
do
|
|
|
{
|
|
{
|
|
|
- result = _server.accept(client);
|
|
|
|
|
|
|
+ ar = _server.accept(client);
|
|
|
}
|
|
}
|
|
|
- while (result.error != AcceptResult::NO_ERROR);
|
|
|
|
|
|
|
+ while (ar.error != AcceptResult::NO_ERROR);
|
|
|
|
|
|
|
|
add_client(client);
|
|
add_client(client);
|
|
|
}
|
|
}
|
|
@@ -55,7 +55,7 @@ void ConsoleServer::send(TCPSocket client, const char* json)
|
|
|
void ConsoleServer::send(const char* json)
|
|
void ConsoleServer::send(const char* json)
|
|
|
{
|
|
{
|
|
|
for (uint32_t i = 0; i < vector::size(_clients); ++i)
|
|
for (uint32_t i = 0; i < vector::size(_clients); ++i)
|
|
|
- send(_clients[i].socket, json);
|
|
|
|
|
|
|
+ send(_clients[i], json);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void ConsoleServer::update()
|
|
void ConsoleServer::update()
|
|
@@ -71,7 +71,7 @@ void ConsoleServer::update()
|
|
|
// Update all clients
|
|
// Update all clients
|
|
|
for (uint32_t i = 0; i < vector::size(_clients); ++i)
|
|
for (uint32_t i = 0; i < vector::size(_clients); ++i)
|
|
|
{
|
|
{
|
|
|
- ReadResult rr = update_client(_clients[i].socket);
|
|
|
|
|
|
|
+ ReadResult rr = update_client(_clients[i]);
|
|
|
if (rr.error != ReadResult::NO_ERROR)
|
|
if (rr.error != ReadResult::NO_ERROR)
|
|
|
array::push_back(to_remove, i);
|
|
array::push_back(to_remove, i);
|
|
|
}
|
|
}
|
|
@@ -90,9 +90,7 @@ void ConsoleServer::update()
|
|
|
|
|
|
|
|
void ConsoleServer::add_client(TCPSocket socket)
|
|
void ConsoleServer::add_client(TCPSocket socket)
|
|
|
{
|
|
{
|
|
|
- Client cl;
|
|
|
|
|
- cl.socket = socket;
|
|
|
|
|
- vector::push_back(_clients, cl);
|
|
|
|
|
|
|
+ vector::push_back(_clients, socket);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ReadResult ConsoleServer::update_client(TCPSocket client)
|
|
ReadResult ConsoleServer::update_client(TCPSocket client)
|