Emergency 20 Dokumentation  4.2.0
MultiplayerProxyClient.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
15 
17 
18 
19 //[-------------------------------------------------------]
20 //[ Namespace ]
21 //[-------------------------------------------------------]
22 namespace em5
23 {
24  namespace multiplayer
25  {
26  namespace proxy
27  {
28 
29 
30  //[-------------------------------------------------------]
31  //[ Classes ]
32  //[-------------------------------------------------------]
38  {
39 
40 
41  //[-------------------------------------------------------]
42  //[ Public boost signals ]
43  //[-------------------------------------------------------]
44  public:
57  boost::signals2::signal<void(const DataData&)> receivedData;
58 
59  boost::signals2::signal<void(CreateSessionResultType, uint64)> sessionCreated;
60  boost::signals2::signal<void(ConnectionResultType)> connectedToSession;
61  boost::signals2::signal<void(uint8)> clientConnectedToSession;
62  boost::signals2::signal<void(uint8)> clientDisconnectedFromSession;
63 
64 
65  //[-------------------------------------------------------]
66  //[ Public methods ]
67  //[-------------------------------------------------------]
68  public:
70 
71  bool connect(const std::string& hostOrIpAddress, uint16 port);
72  void disconnect();
73 
74  void createSession();
75  void disconnectProxyClientFromSession(uint8 proxySessionClientId);
76 
77  bool connectToSession(uint64 sessionId);
79 
80  bool sendData(uint8 proxyClientSessionId, const qsf::game::BitStream& messageData);
81 
82  bool isSessionCreated() const;
83  bool isConnectedToSession() const;
84  uint64 getSessionId() const;
86 
87 
88  //[-------------------------------------------------------]
89  //[ Public virtual qsf::Client methods ]
90  //[-------------------------------------------------------]
91  public:
92  virtual void onConnected() override;
93  virtual void onDisconnected() override;
94  virtual void onUnexpectedDisconnected() override;
95  virtual void onConnectFailed() override;
96 
97 
98  //[-------------------------------------------------------]
99  //[ Protected virtual qsf::game::Client methods ]
100  //[-------------------------------------------------------]
101  protected:
102  virtual void onPacketReceived(const qsf::game::BitStream& bitStream, uint32 sequenceNumber) override;
103 
104 
105  //[-------------------------------------------------------]
106  //[ Private methods ]
107  //[-------------------------------------------------------]
108  private:
109  void splitReceivedMessageIntoMessages(const qsf::game::BitStream& bitStream, uint32 messageSize);
110  void handleMessage(const MessageType messageType, uint32 dataSize, const qsf::game::BitStream& bitStream);
111 
112  void resetStoredData();
113 
114 
115  //[-------------------------------------------------------]
116  //[ Private data ]
117  //[-------------------------------------------------------]
118  private:
119  uint64 mSessionId;
120  uint8 mProxySessionClientId;
121  bool mIsSessionCreator;
122 
123 
124  };
125 
126 
127 //[-------------------------------------------------------]
128 //[ Namespace ]
129 //[-------------------------------------------------------]
130  } // proxy
131  } // multiplayer
132 } // em5
Definition: ActionPriority.h:13
boost::signals2::signal< void(uint8)> clientDisconnectedFromSession
Definition: MultiplayerProxyClient.h:62
unsigned int uint32
Definition: PlatformTypes.h:181
uint64_t uint64
Definition: PlatformTypes.h:184
boost::signals2::signal< void(uint8)> clientConnectedToSession
Definition: MultiplayerProxyClient.h:61
void disconnectProxyClientFromSession(uint8 proxySessionClientId)
Game bit stream class (just a wrapper for linnet bit stream)
Definition: BitStream.h:40
virtual void onDisconnected() override
Called when the client is disconnected.
virtual void onConnected() override
Called when the client is connected.
virtual void onUnexpectedDisconnected() override
Called when the client is disconnected unexpected.
boost::signals2::signal< void(CreateSessionResultType, uint64)> sessionCreated
Definition: MultiplayerProxyClient.h:59
boost::signals2::signal< void(ConnectionResultType)> connectedToSession
Definition: MultiplayerProxyClient.h:60
MessageType
Definition: MultiplayerProxyTypes.h:32
virtual void onConnectFailed() override
Called if the connection attempt failed.
unsigned short uint16
Definition: PlatformTypes.h:178
bool connect(const std::string &hostOrIpAddress, uint16 port)
Game client class.
Definition: Client.h:49
EMERGENCY 5 multiplayer proxy client class.
Definition: MultiplayerProxyClient.h:37
virtual void onPacketReceived(const qsf::game::BitStream &bitStream, uint32 sequenceNumber) override
boost::signals2::signal< void(const DataData &)> receivedData
Called when data is received from the proxy.
Definition: MultiplayerProxyClient.h:57
bool sendData(uint8 proxyClientSessionId, const qsf::game::BitStream &messageData)
unsigned char uint8
Definition: PlatformTypes.h:175