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
ConnectionGraph2.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_ConnectionGraph2==1
23
24 #ifndef __CONNECTION_GRAPH_2_H
25 #define __CONNECTION_GRAPH_2_H
26
27 #include "memoryoverride.h"
28 #include "types.h"
29 #include "PluginInterface2.h"
30 #include "DS_List.h"
31 #include "DS_WeightedGraph.h"
32 #include "GetTime.h"
33 #include "Export.h"
34
35 namespace SLNet
36 {
38 class RakPeerInterface;
39
45 class RAK_DLL_EXPORT ConnectionGraph2 : public PluginInterface2
46 {
47 public:
48
49 // GetInstance() and DestroyInstance(instance*)
50 STATIC_FACTORY_DECLARATIONS(ConnectionGraph2)
51
52 ConnectionGraph2();
53 ~ConnectionGraph2();
54
61 bool GetConnectionListForRemoteSystem(RakNetGUID remoteSystemGuid, SystemAddress *saOut, RakNetGUID *guidOut, unsigned int *outLength);
62
64 bool ConnectionExists(RakNetGUID g1, RakNetGUID g2);
65
67 uint16_t GetPingBetweenSystems(RakNetGUID g1, RakNetGUID g2) const;
68
71 RakNetGUID GetLowestAveragePingSystem(void) const;
72
76 void SetAutoProcessNewConnections(bool b);
77
80 bool GetAutoProcessNewConnections(void) const;
81
87 void AddParticipant(const SystemAddress &systemAddress, RakNetGUID rakNetGUID);
88
91 void GetParticipantList(DataStructures::OrderedList<RakNetGUID, RakNetGUID> &participantList);
92
94 struct SystemAddressAndGuid
95 {
96 SystemAddress systemAddress;
97 RakNetGUID guid;
98 uint16_t sendersPingToThatSystem;
99 };
101 static int SystemAddressAndGuidComp( const SystemAddressAndGuid &key, const SystemAddressAndGuid &data );
102
104 struct RemoteSystem
105 {
106 DataStructures::OrderedList<SystemAddressAndGuid,SystemAddressAndGuid,ConnectionGraph2::SystemAddressAndGuidComp> remoteConnections;
107 RakNetGUID guid;
108 };
110 static int RemoteSystemComp( const RakNetGUID &key, RemoteSystem * const &data );
111
112 protected:
114 virtual void OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason );
116 virtual void OnNewConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming);
118 virtual PluginReceiveResult OnReceive(Packet *packet);
119
120 // List of systems I am connected to, which in turn stores which systems they are connected to
121 DataStructures::OrderedList<RakNetGUID, RemoteSystem*, ConnectionGraph2::RemoteSystemComp> remoteSystems;
122
123 bool autoProcessNewConnections;
124
125 };
126
127 } // namespace SLNet
128
129 #endif // #ifndef __CONNECTION_GRAPH_2_H
130
131 #endif // _RAKNET_SUPPORT_*