SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ReadyEvent.h
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
19
20
21 #include "NativeFeatureIncludes.h"
22 #if _RAKNET_SUPPORT_ReadyEvent==1
23
24 #ifndef __READY_EVENT_H
25 #define __READY_EVENT_H
26
27 #include "PluginInterface2.h"
28 #include "DS_OrderedList.h"
29
30 namespace SLNet {
31
32 class RakPeerInterface;
33
38
41 enum ReadyEventSystemStatus
42 {
46 RES_NOT_WAITING,
48 RES_WAITING,
50 RES_READY,
53 RES_ALL_READY,
54
56 RES_UNKNOWN_EVENT,
57 };
58
68 class ReadyEvent : public PluginInterface2
69 {
70 public:
71 // GetInstance() and DestroyInstance(instance*)
72 STATIC_FACTORY_DECLARATIONS(ReadyEvent)
73
74 // Constructor
75 ReadyEvent();
76
77 // Destructor
78 virtual ~ReadyEvent();
79
80 // --------------------------------------------------------------------------------------------
81 // User functions
82 // --------------------------------------------------------------------------------------------
92 bool SetEvent(int eventId, bool isReady);
93
99 void ForceCompletion(int eventId);
100
105 bool DeleteEvent(int eventId);
106
109 bool IsEventSet(int eventId);
110
116 bool IsEventCompletionProcessing(int eventId) const;
117
123 bool IsEventCompleted(int eventId) const;
124
129 bool HasEvent(int eventId);
130
133 unsigned GetEventListSize(void) const;
134
138 int GetEventAtIndex(unsigned index) const;
139
147 bool AddToWaitList(int eventId, RakNetGUID guid);
148
153 bool RemoveFromWaitList(int eventId, RakNetGUID guid);
154
159 bool IsInWaitList(int eventId, RakNetGUID guid);
160
165 unsigned GetRemoteWaitListSize(int eventId) const;
166
171 RakNetGUID GetFromWaitListAtIndex(int eventId, unsigned index) const;
172
177 ReadyEventSystemStatus GetReadyStatus(int eventId, RakNetGUID guid);
178
181 void SetSendChannel(unsigned char newChannel);
182
183 // ---------------------------- ALL INTERNAL AFTER HERE ----------------------------
186 struct RemoteSystem
187 {
188 MessageID lastSentStatus, lastReceivedStatus;
189 RakNetGUID rakNetGuid;
190 };
191 static int RemoteSystemCompByGuid( const RakNetGUID &key, const RemoteSystem &data );
194 struct ReadyEventNode
195 {
196 int eventId; // Sorted on this
197 MessageID eventStatus;
198 DataStructures::OrderedList<RakNetGUID,RemoteSystem,ReadyEvent::RemoteSystemCompByGuid> systemList;
199 };
200 static int ReadyEventNodeComp( const int &key, ReadyEvent::ReadyEventNode * const &data );
201
202
203 protected:
204 // --------------------------------------------------------------------------------------------
205 // Packet handling functions
206 // --------------------------------------------------------------------------------------------
207 virtual PluginReceiveResult OnReceive(Packet *packet);
208 virtual void OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason );
209 virtual void OnRakPeerShutdown(void);
210
211 void Clear(void);
212 /*
213 bool AnyWaitersCompleted(unsigned eventIndex) const;
214 bool AllWaitersCompleted(unsigned eventIndex) const;
215 bool AllWaitersReady(unsigned eventIndex) const;
216 void SendAllReady(unsigned eventId, RakNetGUID guid);
217 void BroadcastAllReady(unsigned eventIndex);
218 void SendReadyStateQuery(unsigned eventId, RakNetGUID guid);
219 void BroadcastReadyUpdate(unsigned eventIndex);
220 bool AddToWaitListInternal(unsigned eventIndex, RakNetGUID guid);
221 bool IsLocked(unsigned eventIndex) const;
222 bool IsAllReadyByIndex(unsigned eventIndex) const;
223 */
224
225 void SendReadyStateQuery(unsigned eventId, RakNetGUID guid);
226 void SendReadyUpdate(unsigned eventIndex, unsigned systemIndex, bool forceIfNotDefault);
227 void BroadcastReadyUpdate(unsigned eventIndex, bool forceIfNotDefault);
228 void RemoveFromAllLists(RakNetGUID guid);
229 void OnReadyEventQuery(Packet *packet);
230 void PushCompletionPacket(unsigned eventId);
231 bool AddToWaitListInternal(unsigned eventIndex, RakNetGUID guid);
232 void OnReadyEventForceAllSet(Packet *packet);
233 void OnReadyEventPacketUpdate(Packet *packet);
234 void UpdateReadyStatus(unsigned eventIndex);
235 bool IsEventCompletedByIndex(unsigned eventIndex) const;
236 unsigned CreateNewEvent(int eventId, bool isReady);
237 bool SetEventByIndex(int eventIndex, bool isReady);
238
239 DataStructures::OrderedList<int, ReadyEventNode*, ReadyEvent::ReadyEventNodeComp> readyEventNodeList;
240 unsigned char channel;
241 };
242
243 } // namespace SLNet
244
245 #endif
246
247 #endif // _RAKNET_SUPPORT_*