sources/network/rconsession.cpp

branch
protocol5
changeset 130
9f54db6f9922
parent 106
7b156b764d11
child 131
4996c8684b93
--- a/sources/network/rconsession.cpp	Sat Jan 09 17:48:45 2016 +0200
+++ b/sources/network/rconsession.cpp	Mon Jan 25 04:15:31 2016 +0200
@@ -117,18 +117,23 @@
 	}
 
 	for (Datagram datagram; m_socket.read (datagram);)
-		handle_packet (datagram.data, datagram.from);
+		handle_packet (datagram);
 }
 
 // -------------------------------------------------------------------------------------------------
 //
-void RCONSession::handle_packet (Bytestream& packet, const IPAddress& from)
+void RCONSession::handle_packet (Datagram& datagram)
 {
-	if (from != m_address)
+	if (datagram.from != m_address)
 		return;
 
 	try
 	{
+		Bytestream& packet = datagram.data;
+		int32_t header = packet.read_long();
+		int32_t sequenceNumber = (header != 0) ? packet.read_long() : 0;
+		m_interface->print("Recieved packet with header 0x%x and sequence number #%d\n", header, sequenceNumber);
+
 		while (packet.bytes_left() > 0)
 		{
 			int header = packet.read_byte();
@@ -187,6 +192,7 @@
 
 				// Watch sv_hostname so that we can update the titlebar when it changes.
 				request_watch("sv_hostname");
+				m_interface->print ("Watch requested.\n");
 				break;
 
 			case SVRC_UPDATE:
@@ -256,7 +262,7 @@
 				break;
 
 			case SVRC_YOUREDISCONNECTED:
-				m_interface->print ("You have been disconnected: %s", packet.read_string().chars());
+				m_interface->print ("You have been disconnected: %s\n", packet.read_string().chars());
 				m_interface->disconnected();
 				break;
 			}

mercurial