Emergency 20 Dokumentation  4.2.0
HostBase.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 //[-------------------------------------------------------]
14 
15 #include <boost/noncopyable.hpp>
16 #include <boost/signals2.hpp>
17 
18 
19 //[-------------------------------------------------------]
20 //[ Forward declarations ]
21 //[-------------------------------------------------------]
22 namespace qsf
23 {
24  namespace game
25  {
26  class BitStream;
27  }
28  class Clock;
29 }
30 
31 
32 //[-------------------------------------------------------]
33 //[ Namespace ]
34 //[-------------------------------------------------------]
35 namespace em5
36 {
37  namespace multiplayer
38  {
39  namespace client
40  {
41 
42 
43  //[-------------------------------------------------------]
44  //[ Classes ]
45  //[-------------------------------------------------------]
50  class EM5_API_EXPORT HostBase : public boost::noncopyable
51  {
52 
53 
54  //[-------------------------------------------------------]
55  //[ Public boost signals ]
56  //[-------------------------------------------------------]
57  public:
66  boost::signals2::signal<void()> connected;
67 
76  boost::signals2::signal<void()> disconnected;
77 
86  boost::signals2::signal<void()> unexpectedDisconnected;
87 
104  boost::signals2::signal<void(const OperationMessage, uint32, const qsf::game::BitStream&)> receivedOperationMessage;
105 
106 
107  //[-------------------------------------------------------]
108  //[ Public methods ]
109  //[-------------------------------------------------------]
110  public:
115  inline HostBase();
116 
121  inline virtual ~HostBase();
122 
123 
124  //[-------------------------------------------------------]
125  //[ Public virtual em5::multiplayer::client::HostBase methods ]
126  //[-------------------------------------------------------]
127  public:
128  virtual bool connect(const std::string& hostOrIpAddress, uint16 port) = 0;
129 
134  virtual bool sendData(const qsf::game::BitStream& bitStream) = 0;
135 
136  inline virtual void shutdown();
137 
138 
139  //[-------------------------------------------------------]
140  //[ Protected methods ]
141  //[-------------------------------------------------------]
142  protected:
147  void onDataReceived(const qsf::game::BitStream& bitStream);
148 
149 
150  //[-------------------------------------------------------]
151  //[ Private methods ]
152  //[-------------------------------------------------------]
153  private:
154  void splitReceivedMessageIntoOperationMessages(const qsf::game::BitStream& bitStream, uint32 messageSize);
155 
156 
157  };
158 
159 
160 //[-------------------------------------------------------]
161 //[ Namespace ]
162 //[-------------------------------------------------------]
163  } // server
164  } // multiplayer
165 } // em5
166 
167 
168 //[-------------------------------------------------------]
169 //[ Implementation ]
170 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
boost::signals2::signal< void()> disconnected
Called when the client is disconnected.
Definition: HostBase.h:76
boost::signals2::signal< void(const OperationMessage, uint32, const qsf::game::BitStream &)> receivedOperationMessage
Called when a operation message is received from the host server.
Definition: HostBase.h:104
EMERGENCY 5 multiplayer host base class (represents an host on the client side)
Definition: HostBase.h:50
Game bit stream class (just a wrapper for linnet bit stream)
Definition: BitStream.h:40
Definition: PickupPersonByParamedicAction.h:21
unsigned short uint16
Definition: PlatformTypes.h:178
boost::signals2::signal< void()> connected
Called when the connection to the host is established.
Definition: HostBase.h:66
boost::signals2::signal< void()> unexpectedDisconnected
Called when the client is disconnected unexpected.
Definition: HostBase.h:86