Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "NativeFeatureIncludes.h"
00010 #if _RAKNET_SUPPORT_FullyConnectedMesh2==1
00011
00012 #ifndef __FULLY_CONNECTED_MESH_2_H
00013 #define __FULLY_CONNECTED_MESH_2_H
00014
00015 class RakPeerInterface;
00016 #include "PluginInterface2.h"
00017 #include "RakMemoryOverride.h"
00018 #include "DS_Multilist.h"
00019 #include "NativeTypes.h"
00020 #include "DS_List.h"
00021 #include "RakString.h"
00022
00023 typedef int64_t FCM2Guid;
00024
00030 class RAK_DLL_EXPORT FullyConnectedMesh2 : public PluginInterface2
00031 {
00032 public:
00033 FullyConnectedMesh2();
00034 virtual ~FullyConnectedMesh2();
00035
00039 void SetConnectOnNewRemoteConnection(bool attemptConnection, RakNet::RakString pw);
00040
00046 RakNetGUID GetConnectedHost(void) const;
00047 SystemAddress GetConnectedHostAddr(void) const;
00048
00050 RakNetGUID GetHostSystem(void) const;
00051
00053 bool IsHostSystem(void) const;
00054
00057 bool IsConnectedHost(void) const;
00058
00062 void SetAutoparticipateConnections(bool b);
00063
00065 void ResetHostCalculation(void);
00066
00069 void AddParticipant(RakNetGUID rakNetGuid);
00070
00071 unsigned int GetParticipantCount(void) const;
00072 void GetParticipantCount(DataStructures::DefaultIndexType *participantListSize) const;
00074 RakNetTimeUS GetElapsedRuntime(void);
00075
00077 virtual PluginReceiveResult OnReceive(Packet *packet);
00079 virtual void OnRakPeerStartup(void);
00081 virtual void OnAttach(void);
00083 virtual void OnRakPeerShutdown(void);
00085 virtual void OnClosedConnection(SystemAddress systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason );
00087 virtual void OnNewConnection(SystemAddress systemAddress, RakNetGUID rakNetGUID, bool isIncoming);
00088
00090 struct FCM2Participant
00091 {
00092 FCM2Participant() {}
00093 FCM2Participant(const FCM2Guid &_fcm2Guid, const RakNetGUID &_rakNetGuid) : fcm2Guid(_fcm2Guid), rakNetGuid(_rakNetGuid) {}
00094
00095
00096
00097 FCM2Guid fcm2Guid;
00098 RakNetGUID rakNetGuid;
00099 };
00100
00101 protected:
00102 void Clear(void);
00103 void PushNewHost(const RakNetGUID &guid);
00104 void SendOurFCMGuid(SystemAddress addr);
00105 void SendFCMGuidRequest(RakNetGUID rakNetGuid);
00106 void SendConnectionCountResponse(SystemAddress addr, unsigned int responseTotalConnectionCount);
00107 void OnRequestFCMGuid(Packet *packet);
00108 void OnRespondConnectionCount(Packet *packet);
00109 void OnInformFCMGuid(Packet *packet);
00110 void AssignOurFCMGuid(void);
00111 void CalculateHost(RakNetGUID *rakNetGuid, FCM2Guid *fcm2Guid);
00112 bool AddParticipantInternal( RakNetGUID rakNetGuid, FCM2Guid theirFCMGuid );
00113 void CalculateAndPushHost(void);
00114 bool ParticipantListComplete(void);
00115 void IncrementTotalConnectionCount(unsigned int i);
00116
00117
00118 RakNetTimeUS startupTime;
00119
00120
00121 bool autoParticipateConnections;
00122
00123
00124
00125
00126 unsigned int totalConnectionCount;
00127
00128
00129 FCM2Guid ourFCMGuid;
00130
00132 DataStructures::List<FCM2Participant> participantList;
00133
00134 RakNetGUID lastPushedHost;
00135
00136
00137 RakNetGUID hostRakNetGuid;
00138 FCM2Guid hostFCM2Guid;
00139
00140 RakNet::RakString connectionPassword;
00141 bool connectOnNewRemoteConnections;
00142 };
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 #endif
00216
00217 #endif // _RAKNET_SUPPORT_*