BVB Source Codes

CRYENGINE Show RConServerListener.cpp Source code

Return Download CRYENGINE: download RConServerListener.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description: IRemoteControlServerListener implementation
  8.    -------------------------------------------------------------------------
  9.    History:
  10.    - Created by Lin Luo, November 08, 2006
  11. *************************************************************************/
  12.  
  13. #include "StdAfx.h"
  14. #include <CryNetwork/IRemoteControl.h>
  15. #include "RConServerListener.h"
  16.  
  17. CRConServerListener CRConServerListener::s_singleton;
  18.  
  19. IRemoteControlServer* CRConServerListener::s_rcon_server = NULL;
  20.  
  21. CRConServerListener& CRConServerListener::GetSingleton(IRemoteControlServer* rcon_server)
  22. {
  23.         s_rcon_server = rcon_server;
  24.  
  25.         return s_singleton;
  26. }
  27.  
  28. CRConServerListener& CRConServerListener::GetSingleton()
  29. {
  30.         return s_singleton;
  31. }
  32.  
  33. CRConServerListener::CRConServerListener()
  34. {
  35.  
  36. }
  37.  
  38. CRConServerListener::~CRConServerListener()
  39. {
  40.  
  41. }
  42.  
  43. void CRConServerListener::Update()
  44. {
  45.         for (TCommandsMap::const_iterator it = m_commands.begin(); it != m_commands.end(); ++it)
  46.         {
  47.                 gEnv->pConsole->AddOutputPrintSink(this);
  48. #if defined(CVARS_WHITELIST)
  49.                 ICVarsWhitelist* pCVarsWhitelist = gEnv->pSystem->GetCVarsWhiteList();
  50.                 bool execute = (pCVarsWhitelist) ? pCVarsWhitelist->IsWhiteListed(it->second.c_str(), false) : true;
  51.                 if (execute)
  52. #endif // defined(CVARS_WHITELIST)
  53.                 {
  54.                         gEnv->pConsole->ExecuteString(it->second.c_str());
  55.                 }
  56.                 gEnv->pConsole->RemoveOutputPrintSink(this);
  57.  
  58.                 s_rcon_server->SendResult(it->first, m_output);
  59.                 m_output.resize(0);
  60.         }
  61.  
  62.         m_commands.clear();
  63. }
  64.  
  65. void CRConServerListener::Print(const char* inszText)
  66. {
  67.         m_output += string().Format("%s\n", inszText);
  68. }
  69.  
  70. void CRConServerListener::OnStartResult(bool started, EResultDesc desc)
  71. {
  72.         if (started)
  73.                 gEnv->pLog->LogToConsole("RCON: server successfully started");
  74.         else
  75.         {
  76.                 string sdesc;
  77.                 switch (desc)
  78.                 {
  79.                 case eRD_Failed:
  80.                         sdesc = "failed starting server";
  81.                         break;
  82.  
  83.                 case eRD_AlreadyStarted:
  84.                         sdesc = "server already started";
  85.                         break;
  86.                 }
  87.                 gEnv->pLog->LogToConsole("RCON: %s", sdesc.c_str());
  88.  
  89.                 gEnv->pConsole->ExecuteString("rcon_stopserver");
  90.         }
  91. }
  92.  
  93. void CRConServerListener::OnClientAuthorized(string clientAddr)
  94. {
  95.         gEnv->pLog->LogToConsole("RCON: client from %s is authorized", clientAddr.c_str());
  96. }
  97.  
  98. void CRConServerListener::OnAuthorizedClientLeft(string clientAddr)
  99. {
  100.         gEnv->pLog->LogToConsole("RCON: client from %s is gone", clientAddr.c_str());
  101. }
  102.  
  103. void CRConServerListener::OnClientCommand(uint32 commandId, string command)
  104. {
  105.         // execute the command on the server
  106.         gEnv->pLog->LogToConsole("RCON: received remote control command: [%08x]%s", commandId, command.c_str());
  107.  
  108.         m_commands[commandId] = command;
  109. }
  110.  
downloadRConServerListener.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top