BVB Source Codes

CRYENGINE Show RConClientListener.cpp Source code

Return Download CRYENGINE: download RConClientListener.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: IRemoteControlClientListener implementation
  8.    -------------------------------------------------------------------------
  9.    History:
  10.    - Created by Lin Luo, November 09, 2006
  11. *************************************************************************/
  12.  
  13. #include "StdAfx.h"
  14. #include <CryNetwork/IRemoteControl.h>
  15. #include "RConClientListener.h"
  16.  
  17. CRConClientListener CRConClientListener::s_singleton;
  18.  
  19. IRemoteControlClient* CRConClientListener::s_rcon_client = NULL;
  20.  
  21. CRConClientListener& CRConClientListener::GetSingleton(IRemoteControlClient* rcon_client)
  22. {
  23.         s_rcon_client = rcon_client;
  24.  
  25.         return s_singleton;
  26. }
  27.  
  28. CRConClientListener::CRConClientListener()
  29. {
  30.         m_sessionAuthorized = false;
  31. }
  32.  
  33. CRConClientListener::~CRConClientListener()
  34. {
  35.  
  36. }
  37.  
  38. void CRConClientListener::OnConnectResult(bool okay, EResultDesc desc)
  39. {
  40.         if (okay)
  41.                 gEnv->pLog->LogToConsole("RCON: connecting to server");
  42.         else
  43.         {
  44.                 string sdesc;
  45.                 switch (desc)
  46.                 {
  47.                 case eRD_Failed:
  48.                         sdesc = "failed starting up client";
  49.                         break;
  50.  
  51.                 case eRD_CouldNotResolveServerAddr:
  52.                         sdesc = "could not resolve server address";
  53.                         break;
  54.  
  55.                 case eRD_UnsupportedAddressType:
  56.                         sdesc = "unsupported address type for server";
  57.                         break;
  58.  
  59.                 case eRD_ConnectAgain:
  60.                         sdesc = "client already started";
  61.                         break;
  62.                 }
  63.  
  64.                 GameWarning("RCON: %s", sdesc.c_str());
  65.                 gEnv->pConsole->ExecuteString("rcon_disconnect"); // so user don't need to disconnect explicitly
  66.         }
  67. }
  68.  
  69. void CRConClientListener::OnSessionStatus(bool connected, EStatusDesc desc)
  70. {
  71.         if (connected)
  72.         {
  73.                 m_sessionAuthorized = true;
  74.                 gEnv->pLog->LogToConsole("RCON: session successfully connected and authorized");
  75.         }
  76.         else
  77.         {
  78.                 m_sessionAuthorized = false;
  79.  
  80.                 string sdesc;
  81.                 switch (desc)
  82.                 {
  83.                 case eSD_ConnectFailed:
  84.                         sdesc = "failed connecting to server";
  85.                         break;
  86.  
  87.                 case eSD_ServerSessioned:
  88.                         sdesc = "server already in a session";
  89.                         break;
  90.  
  91.                 case eSD_AuthFailed:
  92.                         sdesc = "authorization failed";
  93.                         break;
  94.  
  95.                 case eSD_AuthTimeout:
  96.                         sdesc = "authorization timed out";
  97.                         break;
  98.  
  99.                 case eSD_ServerClosed:
  100.                         sdesc = "server closed";
  101.                         break;
  102.  
  103.                 case eSD_BogusMessage:
  104.                         sdesc = "received bogus message";
  105.                         break;
  106.                 }
  107.                 GameWarning("RCON: session failed - %s", sdesc.c_str());
  108.                 gEnv->pConsole->ExecuteString("rcon_disconnect"); // so user don't need to disconnect explicitly
  109.         }
  110. }
  111.  
  112. void CRConClientListener::OnCommandResult(uint32 commandId, string command, string result)
  113. {
  114.         const char NEWLINE = '\n';
  115.  
  116.         gEnv->pLog->LogToConsole("RCON: command [%08x]%s result:", commandId, command.c_str());
  117.  
  118.         size_t off = 0;
  119.         while (off < result.size())
  120.         {
  121.                 size_t pos = result.find(NEWLINE, off);
  122.                 if (pos == string::npos)
  123.                 {
  124.                         gEnv->pLog->LogToConsole("RCON:\t%s", result.substr(off).c_str());
  125.                         break;
  126.                 }
  127.                 if (pos > off)
  128.                         gEnv->pLog->LogToConsole("RCON:\t%s", result.substr(off, pos - off).c_str());
  129.                 off = pos + 1;
  130.         }
  131. }
  132.  
  133. bool CRConClientListener::IsSessionAuthorized() const
  134. {
  135.         return m_sessionAuthorized;
  136. }
  137.  
downloadRConClientListener.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