Răsfoiți Sursa

Expose send_to_all()

Daniele Bartolini 11 ani în urmă
părinte
comite
c37571221c
2 a modificat fișierele cu 9 adăugiri și 7 ștergeri
  1. 6 6
      engine/console_server.cpp
  2. 3 1
      engine/console_server.h

+ 6 - 6
engine/console_server.cpp

@@ -125,19 +125,19 @@ void ConsoleServer::log_to_all(LogSeverity::Enum severity, const char* message,
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::send(TCPSocket client, const char* message)
+void ConsoleServer::send(TCPSocket client, const char* json)
 {
-	uint32_t msg_len = string::strlen(message);
-	client.write((const char*) &msg_len, 4);
-	client.write(message, msg_len);
+	uint32_t len = string::strlen(json);
+	client.write((const char*)&len, 4);
+	client.write(json, len);
 }
 
 //-----------------------------------------------------------------------------
-void ConsoleServer::send_to_all(const char* message)
+void ConsoleServer::send_to_all(const char* json)
 {
 	for (uint32_t i = 0; i < id_array::size(m_clients); i++)
 	{
-		send(m_clients[i].socket, message);
+		send(m_clients[i].socket, json);
 	}
 }
 

+ 3 - 1
engine/console_server.h

@@ -75,10 +75,12 @@ public:
 	/// Collects requests from clients and processes them all.
 	void update();
 
+	/// Sends the given JSON-encoded string to all clients.
+	void send_to_all(const char* json);
+
 private:
 
 	void send(TCPSocket client, const char* message);
-	void send_to_all(const char* message);
 
 	void add_client(TCPSocket socket);
 	ReadResult update_client(TCPSocket client);