Emergency 20 Dokumentation  4.2.0
ClientBase.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 
16 #include <boost/noncopyable.hpp>
17 #include <boost/signals2.hpp>
18 
19 
20 //[-------------------------------------------------------]
21 //[ Forward declarations ]
22 //[-------------------------------------------------------]
23 namespace qsf
24 {
25  namespace game
26  {
27  class BitStream;
28  }
29 
30  class Clock;
31 }
32 
33 
34 //[-------------------------------------------------------]
35 //[ Namespace ]
36 //[-------------------------------------------------------]
37 namespace em5
38 {
39  namespace multiplayer
40  {
41  namespace server
42  {
43 
44 
45  //[-------------------------------------------------------]
46  //[ Classes ]
47  //[-------------------------------------------------------]
52  class EM5_API_EXPORT ClientBase : public boost::noncopyable
53  {
54 
55 
56  //[-------------------------------------------------------]
57  //[ Public boost signals ]
58  //[-------------------------------------------------------]
59  public:
78  boost::signals2::signal<void(ClientBase&, const OperationMessage, uint64, const qsf::game::BitStream&)> receivedOperationMessage;
79 
80 
81  //[-------------------------------------------------------]
82  //[ Public methods ]
83  //[-------------------------------------------------------]
84  public:
89  inline ClientBase();
90 
95  inline virtual ~ClientBase();
96 
97  inline uint32 getPlayerIndex() const;
98  inline void setPlayerIndex(uint32 playerIndex);
99 
100 
101  //[-------------------------------------------------------]
102  //[ Public virtual em5::multiplayer::server::ClientBase methods ]
103  //[-------------------------------------------------------]
104  public:
105  virtual void disconnect() = 0;
106  virtual void disconnect(bool force) = 0;
107  virtual uint64 getId() const = 0;
108 
116  virtual bool sendData(const qsf::Clock& simulationClock, const qsf::game::BitStream& bitStream) = 0;
117  virtual bool sendData(const qsf::game::BitStream& bitStream) = 0;
118 
119 
120  //[-------------------------------------------------------]
121  //[ Protected methods ]
122  //[-------------------------------------------------------]
123  protected:
128  void onDataReceived(const qsf::game::BitStream& bitStream);
129 
130 
131  //[-------------------------------------------------------]
132  //[ Private methods ]
133  //[-------------------------------------------------------]
134  private:
135  void splitReceivedMessageIntoOperationMessages(const qsf::game::BitStream& bitStream, uint32 messageSize);
136 
137 
138  //[-------------------------------------------------------]
139  //[ Private data ]
140  //[-------------------------------------------------------]
141  private:
142  uint32 mPlayerIndex;
143 
144 
145  };
146 
147 
148 //[-------------------------------------------------------]
149 //[ Namespace ]
150 //[-------------------------------------------------------]
151  } // server
152  } // multiplayer
153 } // em5
154 
155 
156 //[-------------------------------------------------------]
157 //[ Implementation ]
158 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
unsigned int uint32
Definition: PlatformTypes.h:181
Clock class.
Definition: Clock.h:33
#define EM5_API_EXPORT
Definition: Export.h:28
EMERGENCY 5 multiplayer client base class (represents a client on the server side) ...
Definition: ClientBase.h:52
uint64_t uint64
Definition: PlatformTypes.h:184
Game bit stream class (just a wrapper for linnet bit stream)
Definition: BitStream.h:40
Definition: PickupPersonByParamedicAction.h:21
boost::signals2::signal< void(ClientBase &, const OperationMessage, uint64, const qsf::game::BitStream &)> receivedOperationMessage
Called when a operation message is received from the client.
Definition: ClientBase.h:78