sources/network/rconsession.cpp

branch
protocol5
changeset 79
62cfb7b97fc0
parent 78
c1d43ade656e
child 80
f992b027374b
equal deleted inserted replaced
78:c1d43ade656e 79:62cfb7b97fc0
218 m_interface->print ("- %1\n", splice.join (", ")); 218 m_interface->print ("- %1\n", splice.join (", "));
219 } 219 }
220 } 220 }
221 } 221 }
222 break; 222 break;
223
224 case SVRC_WATCHINGCVAR:
225 m_interface->print ("Server acknowledges watch on %1\n", packet.read_string());
226 m_interface->print ("Its current value is %1\n", packet.read_string());
227 break;
228
229 case SVRC_ALREADYWATCHINGCVAR:
230 m_interface->print ("Server says you are already watching %1\n", packet.read_string());
231 break;
232
233 case SVRC_WATCHCVARNOTFOUND:
234 m_interface->print ("No such cvar %1\n", packet.read_string());
235 break;
236
237 case SVRC_CVARCHANGED:
238 {
239 String name = packet.read_string();
240 String value = packet.read_string();
241 m_interface->print ("New value of %1: %2\n", name, value);
242 }
243 break;
223 } 244 }
224 } 245 }
225 } 246 }
226 catch (std::exception& e) 247 catch (std::exception& e)
227 { 248 {
322 bool RCONSession::send_command (const String& message) 343 bool RCONSession::send_command (const String& message)
323 { 344 {
324 if (m_state != RCON_CONNECTED or message.is_empty()) 345 if (m_state != RCON_CONNECTED or message.is_empty())
325 return false; 346 return false;
326 347
348 if (message.starts_with ("/watch "))
349 {
350 String cvarnamelist = message.mid (String ("/watch ").length(), -1);
351 cvarnamelist.normalize();
352
353 Bytestream packet;
354 packet.write_byte (CLRC_WATCHCVAR);
355
356 for (String cvarname : cvarnamelist.split (' '))
357 {
358 m_interface->print (TEXTCOLOR_Green "Requesting watch on %1...\n", cvarname);
359 packet.write_string (cvarname);
360 }
361 send (packet);
362 bump_last_ping();
363 return true;
364 }
365
327 Bytestream packet; 366 Bytestream packet;
328 packet.write_byte (CLRC_COMMAND); 367 packet.write_byte (CLRC_COMMAND);
329 packet.write_string (message); 368 packet.write_string (message);
330 send (packet); 369 send (packet);
331 bump_last_ping(); 370 bump_last_ping();

mercurial