Daniele Bartolini 10 years ago
parent
commit
54377142e6
2 changed files with 8 additions and 20 deletions
  1. 6 8
      src/console_server.cpp
  2. 2 12
      src/console_server.h

+ 6 - 8
src/console_server.cpp

@@ -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)

+ 2 - 12
src/console_server.h

@@ -28,7 +28,7 @@ public:
 
 
 private:
 private:
 
 
-	void send(TCPSocket client, const char* message);
+	void send(TCPSocket client, const char* json);
 
 
 	void add_client(TCPSocket socket);
 	void add_client(TCPSocket socket);
 	ReadResult update_client(TCPSocket client);
 	ReadResult update_client(TCPSocket client);
@@ -40,18 +40,8 @@ private:
 
 
 private:
 private:
 
 
-	struct Client
-	{
-		TCPSocket socket;
-
-		void close()
-		{
-			socket.close();
-		}
-	};
-
 	TCPSocket _server;
 	TCPSocket _server;
-	Vector<Client> _clients;
+	Vector<TCPSocket> _clients;
 };
 };
 
 
 /// Functions for accessing global console.
 /// Functions for accessing global console.