ReplicaNet and RNLobby  1
Public Types | Public Member Functions | List of all members
NATDetectClient Class Reference

#include <NATDetectClient.h>

Inheritance diagram for NATDetectClient:
Inheritance graph
[legend]
Collaboration diagram for NATDetectClient:
Collaboration graph
[legend]

Public Types

enum  NATType { kOpen = 0, kModerate, kStrict }
 
- Public Types inherited from MutexClass
enum  { kNoOwnerThread = -1 }
 

Public Member Functions

bool Start (const int channel=TransportAnyGameChannel)
 
void SetServers (const XPAddress &address1, const XPAddress &address2)
 Sets the address and port of the servers. The default for the instance of the class is localhost and port NATDetectServer::kDefaultPort and NATDetectServer::kDefaultPort+1 or the address resolved by a successful BackendClient::Start().
 
bool GetCompleted (void)
 
NATDetectServer::Reply GetReply (void)
 
NATType GetNATType (void) const
 If GetReply() == NATDetectServer::kReply_Success this returns the type of NAT calculated by this class.
 
XPAddress GetPublicAddress (void) const
 Returns the public internet address of this computer as seen by the NATDetectServer.
 
virtual void CallbackCompleted (void)
 A virtual callback that is triggered when the NATDetect calculation is complete. GetReply(), GetNATType() and GetPublicAddress() can be used during this callback or at any time after completion.
 
void GetAddressReplies (XPAddress &addr1, XPAddress &addr2)
 Gets the two addresses as seen by the NATDetectServer.
 
- Public Member Functions inherited from BaseServer
virtual bool StartWithSocket (t_XPSocket *socket, const bool allowDelete=true)
 
virtual bool Stop (void)
 
void SetEncryptionKey (const void *data, const int length)
 
virtual void CallbackDataReceived (DynamicMessageHelper &message, XPAddress &address)
 
virtual void CallbackDataSend (DynamicMessageHelper &message, XPAddress &address)
 
virtual void CallbackQueryReplyTime (const float seconds)
 
virtual void CallbackTidy (void)
 
- Public Member Functions inherited from ThreadClass
 ThreadClass ()
 
virtual ~ThreadClass ()
 
void Sleep (int milliseconds)
 
- Public Member Functions inherited from MutexClass
 MutexClass ()
 
virtual ~MutexClass ()
 
void Lock (void)
 
void UnLock (void)
 
- Public Member Functions inherited from Thread
 Thread ()
 
virtual ~Thread ()
 
void Begin (ThreadClass *threaded_class)
 
void Terminate (void)
 
bool GetTerminated (void)
 
bool GetEverTerminated (void)
 
bool GetIsRunning (void) const
 
void SetPreferredProcessor (int processor=kReplicaNetPreferredProcessorOSChoice)
 
int GetPreferredProcessor (void)
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseServer
static SysTimeType FloatTime (void)
 
- Static Public Member Functions inherited from Thread
static int CallThreadEntry (ThreadClass *thread_class)
 
static int GetCurrentProcessorNumber (void)
 
static size_t GetNumAllocated (void)
 
static size_t GetNumActive (void)
 
- Protected Member Functions inherited from BaseServer
virtual bool PackageAndSendData (t_XPSocket *socket, const DynamicMessageHelper &message, const XPAddress &address)
 
virtual bool CallbackParsePacketData (t_XPSocket *socket, const XPAddress &addr, void *data, size_t &length, DynamicMessageHelper &result)
 
int ThreadEntry (void)
 
- Protected Member Functions inherited from ThreadClass
void DoQuitNow (const int returnCode)
 
void CheckQuit (void)
 
- Static Protected Member Functions inherited from ThreadClass
static size_t GetNumAllocated (void)
 
- Protected Attributes inherited from BaseServer
t_XPSocketmSocket
 
bool mAllowDelete
 
int mNOnce
 

Detailed Description

This class interrogates the network connection of a machine to determine the if there is any NAT implemented to known external machines.

Member Function Documentation

bool GetCompleted ( void  )

Tests the completion state of the last query. When the query completes the result can be retrieved by using GetReply()

Returns
A completed query returns true, a pending query returns false.
NATDetectServer::Reply GetReply ( void  )

Returns the last reply from a completed query.

Returns
The last reply from a completed query.
bool Start ( const int  channel = TransportAnyGameChannel)

If using a specific game channel for ReplicaNet/XPSession then remember to stop the NATDetectClient service before calling ReplicaNet::SessionCreate()/XPSession::Create() so the game channel is free for ReplicaNet/XPSession to use.