Browse Source

fix rpc, use default allocator instead of linear allocator

mikymod 12 years ago
parent
commit
ee8e9892f9
2 changed files with 9 additions and 9 deletions
  1. 9 6
      engine/rpc/RPCServer.cpp
  2. 0 3
      engine/rpc/RPCServer.h

+ 9 - 6
engine/rpc/RPCServer.cpp

@@ -37,10 +37,8 @@ namespace crown
 //-----------------------------------------------------------------------------
 RPCServer::RPCServer()
 	: m_num_clients(0)
-	, m_receive_allocator(default_allocator(), 16 * 1024)
-	, m_send_allocator(default_allocator(), 16 * 1024)
-	, m_receive_buffer(m_receive_allocator)
-	, m_send_buffer(m_send_allocator)
+	, m_receive_buffer(default_allocator())
+	, m_send_buffer(default_allocator())
 	, m_handlers_head(NULL)
 	, m_receive_callbacks(default_allocator())
 	, m_send_callbacks(default_allocator())
@@ -191,7 +189,6 @@ void RPCServer::execute_callbacks()
 
 	m_receive_callbacks.clear();
 	m_receive_buffer.clear();
-	m_receive_allocator.clear();
 
 	for (uint32_t i = 0; i < m_send_callbacks.size(); i++)
 	{
@@ -203,7 +200,6 @@ void RPCServer::execute_callbacks()
 
 	m_send_callbacks.clear();
 	m_send_buffer.clear();
-	m_send_allocator.clear();
 }
 
 //-----------------------------------------------------------------------------
@@ -223,6 +219,12 @@ void RPCServer::update_client(ClientId id)
 		{
 			if (result.received_bytes > 0)
 			{
+				for (uint32_t i = 0; i < result.received_bytes; i++)
+			 	{
+			 		printf("%c", buf[i]);
+			 	}
+			 	printf("\n");
+
 				m_receive_buffer.push(buf, result.received_bytes);
 				total_read += result.received_bytes;
 				continue;
@@ -247,6 +249,7 @@ void RPCServer::update_client(ClientId id)
 	if (total_read > 0)
 	{
 		JSONParser parser(&m_receive_buffer[message_index]);
+		Log::d("%s", &m_receive_buffer[message_index]);
 		JSONElement root = parser.root();
 		JSONElement type = root.key_or_nil("type");
 

+ 0 - 3
engine/rpc/RPCServer.h

@@ -30,7 +30,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "List.h"
 #include "Queue.h"
 #include "IdTable.h"
-#include "LinearAllocator.h"
 #include "Log.h"
 
 namespace crown
@@ -86,8 +85,6 @@ private:
 	IdTable<MAX_RPC_CLIENTS> 	m_clients_table;
 	TCPSocket					m_clients[MAX_RPC_CLIENTS];
 
-	LinearAllocator				m_receive_allocator;
-	LinearAllocator				m_send_allocator;
 	List<char>					m_receive_buffer;
 	List<char>					m_send_buffer;