11 #include "RNPlatform/Inc/MemoryTracking.h"
12 #ifndef _ADVERTISECLIENT_H_
13 #define _ADVERTISECLIENT_H_
14 #include "RNLobby/Inc/BaseTransportServer.h"
15 #include "RNXPSockets/Inc/XPSocket.h"
16 #include "RNLobby/Inc/UserClient.h"
19 namespace RNReplicaNet
66 bool GetListings(
const unsigned int maxResults = 10,
const unsigned int offset = 0,
const char *filter = 0);
87 bool AddRule(
const char *rule,
const char *userData =
"");
94 bool AddPlayer(
const char *name,
const char *userData =
"",
const int loginID = UserInfo::kAnyLoginID);
126 virtual void CallbackListingsEntry(
const int serverIndex,
const int hostLoginID,
const char *url,
const char *userData,
const float age,
const XPAddress &address) {}
138 virtual void CallbackRule(
const int serverIndex,
const char *rule,
const char *userData) {}
153 virtual void CallbackPlayer(
const int serverIndex,
const char *name,
const char *userData,
const int loginID) {}
163 virtual void CallbackLatencyTo(
const int serverIndex,
const float latency,
const float packetLossPercent) {}
183 std::string mCurrentURL;
184 std::string mCurrentUserData;
196 std::string mBroadcastURL;
197 std::string mBroadcastData;
198 std::map<int,XPAddress> mGotReplyFrom;
199 int mBroadcastServerID;
202 SysTimeType mRequestListingTime;
203 std::list<std::pair<SysTimeType,int> > mRequestRulesTimes;
204 std::list<std::pair<SysTimeType,int> > mRequestPlayersTimes;
210 void StartLatencyCalculate(
void);
213 float GetLatency(
void);
215 float GetPacketLoss(
void);
223 SysTimeType mLastPingSentTime;
226 SysTimeType mTotalRoundTripTime;
236 std::map<int,ServerInfo> mLocalServerInfo;
237 std::multimap<XPAddress,int> mServerIndexByAddress;
238 std::list<int> mServerIDsPingFinished;
239 bool mAnyActivePings;
244 void ThreadExiting(
const int returnCode);
252 bool mServerAddressSet;
virtual void CallbackRulesComplete(const int serverIndex)
Definition: AdvertiseClient.h:142
virtual void CallbackLatencyTo(const int serverIndex, const float latency, const float packetLossPercent)
Definition: AdvertiseClient.h:163
Definition: Transport.h:35
bool SendReliableMessage(const int serverIndex, const void *data, const int length)
A server base class that handles encrypted messages to and from a transport.
Definition: BaseTransportServer.h:30
virtual void CallbackWantRules(void)
This is called by AdvertiseClient when the user needs to supply rules for the currently advertised se...
Definition: AdvertiseClient.h:108
void SetServer(const XPAddress &address)
Definition: XPSocket.h:91
bool StartLAN(void)
This starts this class to only advertise and find sessions on the LAN.
bool AddPlayer(const char *name, const char *userData="", const int loginID=UserInfo::kAnyLoginID)
virtual void CallbackListingsBegin(void)
This is called at the start when the listings are refreshed.
Definition: AdvertiseClient.h:117
virtual void CallbackListingsEntry(const int serverIndex, const int hostLoginID, const char *url, const char *userData, const float age, const XPAddress &address)
Definition: AdvertiseClient.h:126
bool RulesChanged(void)
The user may call this notify the server that the session rules have changed. This then causes a new ...
bool RequestPlayers(const int serverIndex)
Request the players for a specific server. CallbackPlayersBegin etc will be called when the players h...
virtual void CallbackListingsComplete(void)
This is called when there are no more listings.
Definition: AdvertiseClient.h:129
virtual void CallbackConnectionEstablished(Transport *transport)
User extensible callbacks.
Definition: AdvertiseClient.h:105
bool RequestRules(const int serverIndex)
Request the rules for a specific server. CallbackRulesBegin etc will be called when the rules have be...
virtual void CallbackMessageReceived(const int sourceLoginID, const void *data, const int length)
Definition: AdvertiseClient.h:169
bool StopListings(void)
Stop the current request for listings.
virtual void CallbackGotServerIndex(const int serverIndex)
This is called when the server index is known for the currently advertised server.
Definition: AdvertiseClient.h:114
Maintains a connection to the AdvertiseServer.
Definition: AdvertiseClient.h:26
Definition: AdvertiseClient.h:206
virtual void CallbackRule(const int serverIndex, const char *rule, const char *userData)
Definition: AdvertiseClient.h:138
bool StopAdvertiseSession(void)
bool CallbackParseValidMessage(Transport *transport, DynamicMessageHelper &message, const size_t length)
bool Start(void)
Because this uses a TransportUDP connection it will call XPURL::RegisterDefaultTransports() ...
virtual void CallbackRulesBegin(const int serverIndex)
This is called the start when the rules for a server index are updated.
Definition: AdvertiseClient.h:132
Definition: XPSocket.h:167
bool RequestLatency(const int serverIndex)
bool PlayersChanged(void)
The user may call this notify the server that the session players list has changed. This then causes a new players list to be requested by CallbackWantPlayers.
Definition: MessageHelper.h:211
bool AdvertiseSession(const char *url, const char *userData="")
virtual void CallbackPlayer(const int serverIndex, const char *name, const char *userData, const int loginID)
Definition: AdvertiseClient.h:153
bool GetListings(const unsigned int maxResults=10, const unsigned int offset=0, const char *filter=0)
virtual void CallbackPlayersComplete(const int serverIndex)
Definition: AdvertiseClient.h:157
bool GetAnyActivePings(void) const
Returns true if there are any pings active.
virtual void CallbackPlayersBegin(const int serverIndex)
Definition: AdvertiseClient.h:146
bool AddRule(const char *rule, const char *userData="")
Definition: AdvertiseClient.h:230
Definition: XPSocketUrgentClass.h:26
virtual void CallbackWantPlayers(void)
This is called by AdvertiseClient when the user needs to supply players for the currently advertised ...
Definition: AdvertiseClient.h:111
Definition: ThreadClass.h:96