sources/network/rconsession.cpp

changeset 152
6be21be4bea1
parent 145
d0aedc9be448
child 153
82aac80a2f1d
child 156
ce66d7e374bf
--- a/sources/network/rconsession.cpp	Wed Jul 20 17:53:13 2016 +0300
+++ b/sources/network/rconsession.cpp	Wed Jul 20 18:20:20 2016 +0300
@@ -116,21 +116,21 @@
 	}
 
 	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.address != m_address)
 		return;
 
 	try
 	{
-		while (packet.bytes_left() > 0)
+		while (datagram.message.bytes_left() > 0)
 		{
-			int header = packet.read_byte();
+			int header = datagram.message.read_byte();
 
 			switch (ServerResponse (header))
 			{
@@ -145,7 +145,7 @@
 				break;
 
 			case SVRC_SALT:
-				m_salt = packet.read_string();
+				m_salt = datagram.message.read_string();
 				m_state = RCON_AUTHENTICATING;
 				send_password();
 				break;
@@ -157,7 +157,7 @@
 
 			case SVRC_MESSAGE:
 				{
-					String message = packet.read_string();
+					String message = datagram.message.read_string();
 					message.normalize();
 					m_interface->printText ("%s\n", message.chars());
 				}
@@ -165,19 +165,19 @@
 
 			case SVRC_LOGGEDIN:
 				m_interface->print ("Login successful!\n");
-				m_serverProtocol = packet.read_byte();
-				m_hostname = packet.read_string();
+				m_serverProtocol = datagram.message.read_byte();
+				m_hostname = datagram.message.read_string();
 				m_interface->setTitle (m_hostname);
 				m_state = RCON_CONNECTED;
 
-				for (int i = packet.read_byte(); i > 0; --i)
-					process_server_updates (packet);
+				for (int i = datagram.message.read_byte(); i > 0; --i)
+					process_server_updates (datagram.message);
 
 				m_interface->print ("Previous messages:\n");
 
-				for (int i = packet.read_byte(); i > 0; --i)
+				for (int i = datagram.message.read_byte(); i > 0; --i)
 				{
-					String message = packet.read_string();
+					String message = datagram.message.read_string();
 					message.normalize();
 					m_interface->printText ("--- %s\n", message.chars());
 				}
@@ -186,12 +186,12 @@
 				break;
 
 			case SVRC_UPDATE:
-				process_server_updates (packet);
+				process_server_updates (datagram.message);
 				break;
 
 			case SVRC_TOOMANYTABCOMPLETES:
 				{
-					unsigned int numCompletions = packet.read_short();
+					unsigned int numCompletions = datagram.message.read_short();
 					m_interface->print ("%d completions for '%s'.\n",
 						int (numCompletions), m_lastTabComplete.chars());
 				}
@@ -200,10 +200,10 @@
 			case SVRC_TABCOMPLETE:
 				{
 					StringList completes;
-					completes.resize(packet.read_byte());
+					completes.resize(datagram.message.read_byte());
 
 					for (String& completion : completes)
-						completion = packet.read_string();
+						completion = datagram.message.read_string();
 
 					if (completes.size() == 1)
 					{

mercurial