BVB Source Codes

CRYENGINE Show GameServerChannel.h Source code

Return Download CRYENGINE: download GameServerChannel.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description:
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    - 11:8:2004   11:39 : Created by M谩rcio Martins
  12.  
  13. *************************************************************************/
  14. #ifndef __GAMESERVERCHANNEL_H__
  15. #define __GAMESERVERCHANNEL_H__
  16.  
  17. #if _MSC_VER > 1000
  18.         #pragma once
  19. #endif
  20.  
  21. #include "GameChannel.h"
  22. #include <CryNetwork/INetwork.h>
  23.  
  24. // toggle between a fast and a somewhat safer cvar synchronization (whilst debugging it)
  25. #define FAST_CVAR_SYNC 0
  26.  
  27. class CGameServerNub;
  28. class CGameContext;
  29.  
  30. #ifndef OLD_VOICE_SYSTEM_DEPRECATED
  31. struct SMutePlayerParams
  32. {
  33.         SMutePlayerParams()
  34.                 : mute(false)
  35.                 , requestor(INVALID_ENTITYID)
  36.                 , id(INVALID_ENTITYID)
  37.         {
  38.         }
  39.  
  40.         EntityId     requestor; // player requesting the mute
  41.         EntityId     id;        // player to mute
  42.         bool         mute;
  43.  
  44.         virtual void SerializeWith(TSerialize ser)
  45.         {
  46.                 ser.Value("requestor", requestor, 'eid');
  47.                 ser.Value("id", id, 'eid');
  48.                 ser.Value("mute", mute);
  49.         }
  50. };
  51. #endif
  52.  
  53. #if defined(GAME_CHANNEL_SYNC_CLIENT_SERVER_TIME)
  54.  
  55. struct SSyncTimeServer
  56. {
  57.         SSyncTimeServer() {};
  58.         SSyncTimeServer(int id, int64 clientTime, int64 serverTime) { this->id = id; this->clientTime = clientTime; this->serverTime = serverTime; };
  59.  
  60.         int          id;
  61.         int64        clientTime;
  62.         int64        serverTime;
  63.  
  64.         virtual void SerializeWith(TSerialize ser)
  65.         {
  66.                 ser.Value("id", id);
  67.                 ser.Value("clientTime", clientTime);
  68.                 ser.Value("serverTime", serverTime);
  69.         }
  70. };
  71.  
  72. #endif //GAME_CHANNEL_SYNC_CLIENT_SERVER_TIME
  73.  
  74. class CGameServerChannel :
  75.         public CNetMessageSinkHelper<CGameServerChannel, CGameChannel>, public IConsoleVarSink
  76. {
  77. public:
  78.         CGameServerChannel(INetChannel* pNetChannel, CGameContext* pGameContext, CGameServerNub* pServerNub);
  79.         virtual ~CGameServerChannel();
  80.  
  81. #if !NEW_BANDWIDTH_MANAGEMENT
  82.         void SetupNetChannel(INetChannel* pNetChannel);
  83. #endif // !NEW_BANDWIDTH_MANAGEMENT
  84.         bool IsOnHold() const     { return m_onHold; };
  85.         void SetOnHold(bool hold) { m_onHold = hold; };
  86.  
  87.         // IGameChannel
  88.         virtual void Release() override;
  89.         virtual void OnDisconnect(EDisconnectionCause cause, const char* description) override;
  90.         // ~IGameChannel
  91.  
  92.         // GameChannel
  93.         virtual bool IsServer() const override { return true; }
  94.         //~GameChannel
  95.  
  96.         // INetMessageSink
  97.         virtual void DefineProtocol(IProtocolBuilder* pBuilder) override;
  98.         // ~INetMessageSink
  99.  
  100.         // IConsoleVarSink
  101.         virtual bool OnBeforeVarChange(ICVar* pVar, const char* sNewValue) override;
  102.         virtual void OnAfterVarChange(ICVar* pVar) override;
  103.         // ~IConsoleVarSink
  104.  
  105.         void SetChannelId(uint16 channelId)
  106.         {
  107.                 m_channelId = channelId;
  108.         };
  109.         uint16 GetChannelId() const
  110.         {
  111.                 return m_channelId;
  112.         };
  113.  
  114.         void SetPlayerId(EntityId playerId);
  115.  
  116. #if FAST_CVAR_SYNC
  117.         SSendableHandle& GetConsoleStreamId(const string& name)
  118.         {
  119.                 return m_consoleVarStreamId[name];
  120.         }
  121. #endif
  122.  
  123.         bool CheckLevelLoaded() const;
  124.         void AddUpdateLevelLoaded(IContextEstablisher* pEst);
  125.  
  126.         void GetMemoryUsage(ICrySizer* s) const
  127.         {
  128.                 s->AddObject(this, sizeof(*this));
  129. #if FAST_CVAR_SYNC
  130.                 s->AddObject(m_consoleVarStreamId);
  131.                 for (std::map<string, SSendableHandle>::iterator iter = m_consoleVarStreamId.begin(); iter != m_consoleVarStreamId.end(); ++iter)
  132.                         s->Add(iter->first);
  133. #endif
  134.         }
  135.  
  136.         // mute players' voice comms
  137. #ifndef OLD_VOICE_SYSTEM_DEPRECATED
  138.         NET_DECLARE_SIMPLE_ATSYNC_MESSAGE(MutePlayer, SMutePlayerParams);
  139. #endif
  140.  
  141. #if defined(GAME_CHANNEL_SYNC_CLIENT_SERVER_TIME)
  142.         NET_DECLARE_SIMPLE_ATSYNC_MESSAGE(SyncTimeServer, SSyncTimeServer);
  143. #endif
  144.  
  145. private:
  146.         void Cleanup();
  147.  
  148.         CGameServerNub* m_pServerNub;
  149.  
  150.         uint16          m_channelId;
  151.         bool            m_hasLoadedLevel;
  152.         bool            m_onHold;
  153.  
  154. #if FAST_CVAR_SYNC
  155.         std::map<string, SSendableHandle> m_consoleVarStreamId;
  156. #else
  157.         SSendableHandle                   m_consoleVarSendable;
  158. #endif
  159.  
  160.         static ICVar* sv_timeout_disconnect;
  161. };
  162.  
  163. #endif //__GAMESERVERCHANNEL_H__
  164.  
downloadGameServerChannel.h 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