sources/network/rconsession.cpp

branch
protocol5
changeset 103
b78c0ca832a9
parent 84
3bd32eec3d57
child 104
a76af67a3a4b
--- a/sources/network/rconsession.cpp	Wed May 27 21:15:52 2015 +0300
+++ b/sources/network/rconsession.cpp	Sat Jan 09 02:20:28 2016 +0200
@@ -221,6 +221,29 @@
 					}
 				}
 				break;
+
+			case SVRC_WATCHINGCVAR:
+				m_interface->print ("You are now watching %s\n", packet.read_string().chars());
+				m_interface->print ("Its value is: %s\n", packet.read_string().chars());
+				break;
+
+			case SVRC_ALREADYWATCHINGCVAR:
+				m_interface->print ("You are already watching %s\n", packet.read_string().chars());
+				break;
+
+			case SVRC_WATCHCVARNOTFOUND:
+				m_interface->print ("CVar %s not found\n", packet.read_string().chars());
+				break;
+
+			case SVRC_CVARCHANGED:
+				m_interface->print ("The value of CVar %s", packet.read_string().chars());
+				m_interface->print (" is now %s\n", packet.read_string().chars());
+				break;
+
+			case SVRC_YOUREDISCONNECTED:
+				m_interface->print ("You have been disconnected: %s", packet.read_string().chars());
+				m_interface->disconnected();
+				break;
 			}
 		}
 	}
@@ -326,8 +349,32 @@
 		return false;
 
 	Bytestream packet;
-	packet.write_byte (CLRC_COMMAND);
-	packet.write_string (message);
+
+	// Let's hardcode a /watch for CVar watching testing purposes
+	if (message.starts_with ("/watch "))
+	{
+		StringList cvars = message.mid(String("/watch ").length(), -1).split(',');
+		packet.write_byte(CLRC_WATCHCVAR);
+
+		for (int i = 0 ; i < cvars.size(); ++i)
+		{
+			String cvar = cvars[i].normalized();
+
+			if (not cvar.is_empty())
+			{
+				packet.write_string(cvar);
+				m_interface->print("Requesting watch of %s\n", cvar.chars());
+			}
+		}
+
+		packet.write_string("");
+	}
+	else
+	{
+		packet.write_byte (CLRC_COMMAND);
+		packet.write_string (message);
+	}
+
 	send (packet);
 	bump_last_ping();
 	return true;
@@ -378,4 +425,4 @@
 	{
 		m_interface->print ("This server does not support tab-completion\n", m_serverProtocol);
 	}
-}
\ No newline at end of file
+}

mercurial