Explorar o código

AsyncConnection fixed, data received correctly

mikymod %!s(int64=13) %!d(string=hai) anos
pai
achega
d12c8a8998
Modificáronse 2 ficheiros con 17 adicións e 17 borrados
  1. 0 1
      src/network/AsyncConnection.cpp
  2. 17 16
      tests/connections.cpp

+ 0 - 1
src/network/AsyncConnection.cpp

@@ -167,7 +167,6 @@ void AsyncConnection::send_message(BitMessage& msg, const uint32_t time)
 {
 	assert(m_running);
 	
-	msg.init(MAX_MESSAGE_SIZE);
 	m_socket.send(m_remote_address, msg.get_data(), msg.get_size());
 
 }

+ 17 - 16
tests/connections.cpp

@@ -55,7 +55,6 @@ int main(int argc, char** argv)
 	
 	uint16_t port = mode == SERVER ? server_port : client_port;
 
-	
 	// connection init
 	connection.init(protocol_id, 10.0f);
 	//connection start
@@ -92,20 +91,6 @@ int main(int argc, char** argv)
                 
         send_acc += delta_time;
 		
-		if (mode == CLIENT)
-		{
-			while (send_acc > 1 / send_rate)
-			{
-				network::BitMessage message(alloc);
-			
-				message.init(6);
-				message.write_string("prova", 6);
-				
-				connection.send_message(message, delta_time);
-				
-				send_acc -= 1.0f / send_rate;
-			}
-		}
 		if (mode == SERVER)
 		{
 			while (true)
@@ -119,7 +104,8 @@ int main(int argc, char** argv)
 				{
 					char string[6];
 					received.read_string(string, 6);
-// 					os::printf("%s\n", string);
+ 					os::printf("%s\n", string);
+					
 				} 
 				
 				if (bytes <= 0)
@@ -128,6 +114,21 @@ int main(int argc, char** argv)
 				}
 			}
 		}
+		
+		if (mode == CLIENT)
+		{
+			while (send_acc > 1 / send_rate)
+			{
+				network::BitMessage message(alloc);
+			
+				message.init(6);
+				message.write_string("prova", 6);
+				
+				connection.send_message(message, delta_time);
+				
+				send_acc -= 1.0f / send_rate;
+			}
+		}
 	}
 	
 	connection.stop();