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
UDPProxyCoordinator.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_UDPProxyCoordinator==1 && _RAKNET_SUPPORT_UDPForwarder==1
23
24 #ifndef __UDP_PROXY_COORDINATOR_H
25 #define __UDP_PROXY_COORDINATOR_H
26
27 #include "Export.h"
28 #include "types.h"
29 #include "PluginInterface2.h"
30 #include "string.h"
31 #include "BitStream.h"
32 #include "DS_Queue.h"
33 #include "DS_OrderedList.h"
34
35 namespace SLNet
36 {
42 class RAK_DLL_EXPORT UDPProxyCoordinator : public PluginInterface2
43 {
44 public:
45 // GetInstance() and DestroyInstance(instance*)
46 STATIC_FACTORY_DECLARATIONS(UDPProxyCoordinator)
47
48 UDPProxyCoordinator();
49 virtual ~UDPProxyCoordinator();
50
54 void SetRemoteLoginPassword(SLNet::RakString password);
55
57 virtual void Update(void);
58 virtual PluginReceiveResult OnReceive(Packet *packet);
59 virtual void OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason );
60
61 struct SenderAndTargetAddress
62 {
63 SystemAddress senderClientAddress;
64 RakNetGUID senderClientGuid;
65 SystemAddress targetClientAddress;
66 RakNetGUID targetClientGuid;
67 };
68
69 struct ServerWithPing
70 {
71 unsigned short ping;
72 SystemAddress serverAddress;
73 };
74
75 struct ForwardingRequest
76 {
77 SLNet::TimeMS timeoutOnNoDataMS;
78 SLNet::TimeMS timeoutAfterSuccess;
79 SenderAndTargetAddress sata;
80 SystemAddress requestingAddress; // Which system originally sent the network message to start forwarding
81 SystemAddress currentlyAttemptedServerAddress;
82 DataStructures::Queue<SystemAddress> remainingServersToTry;
83 SLNet::BitStream serverSelectionBitstream;
84
85 DataStructures::List<ServerWithPing> sourceServerPings, targetServerPings;
86 SLNet::TimeMS timeRequestedPings;
87 // Order based on sourceServerPings and targetServerPings
88 void OrderRemainingServersToTry(void);
89
90 };
91 protected:
92
93 static int ServerWithPingComp( const unsigned short &key, const UDPProxyCoordinator::ServerWithPing &data );
94 static int ForwardingRequestComp( const SenderAndTargetAddress &key, ForwardingRequest* const &data);
95
96 void OnForwardingRequestFromClientToCoordinator(Packet *packet);
97 void OnLoginRequestFromServerToCoordinator(Packet *packet);
98 void OnForwardingReplyFromServerToCoordinator(Packet *packet);
99 void OnPingServersReplyFromClientToCoordinator(Packet *packet);
100 void TryNextServer(SenderAndTargetAddress sata, ForwardingRequest *fw);
101 void SendAllBusy(SystemAddress senderClientAddress, SystemAddress targetClientAddress, RakNetGUID targetClientGuid, SystemAddress requestingAddress);
102 void Clear(void);
103
104 void SendForwardingRequest(SystemAddress sourceAddress, SystemAddress targetAddress, SystemAddress serverAddress, SLNet::TimeMS timeoutOnNoDataMS);
105
106 // Logged in servers
107 //DataStructures::Multilist<ML_UNORDERED_LIST, SystemAddress> serverList;
108 DataStructures::List<SystemAddress> serverList;
109
110 // Forwarding requests in progress
111 //DataStructures::Multilist<ML_ORDERED_LIST, ForwardingRequest*, SenderAndTargetAddress> forwardingRequestList;
112 DataStructures::OrderedList<SenderAndTargetAddress, ForwardingRequest*, ForwardingRequestComp> forwardingRequestList;
113
114 SLNet::RakString remoteLoginPassword;
115
116 };
117
118 } // End namespace
119
120 #endif
121
122 #endif // _RAKNET_SUPPORT_*