00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _NATDETECTCLIENT_H_
00012 #define _NATDETECTCLIENT_H_
00013 #include "RNPlatform/Inc/DLLExportAPI.h"
00014 #include "RNLobby/Inc/NATDetectServer.h"
00015 #include "RNXPURL/Inc/Transport.h"
00016
00017 namespace RNReplicaNet
00018 {
00019
00020 namespace RNLobby
00021 {
00022
00025 class NATDetectClient : public BaseServer
00026 {
00027 public:
00028 enum NATType
00029 {
00030 kOpen = 0,
00031 kModerate,
00032 kStrict
00033 };
00034
00035 NATDetectClient();
00036 virtual ~NATDetectClient();
00037
00040 bool Start(const int channel = TransportAnyGameChannel);
00041
00043 void SetServers(const XPAddress &address1,const XPAddress &address2);
00044
00047 bool GetCompleted(void);
00048
00051 NATDetectServer::Reply GetReply(void);
00052
00054 NATType GetNATType(void) const;
00055
00057 XPAddress GetPublicAddress(void) const;
00058
00060 virtual void CallbackCompleted(void) {}
00061
00062 private:
00063 void Init(void);
00064 bool CallbackParseValidMessage(DynamicMessageHelper &message,const size_t length,const XPAddress &address);
00065 bool DoSuccessState(void);
00066
00067 bool CallbackPoll(void);
00068
00069 float mLastSentTime;
00070 int mGot1Times;
00071 int mGot2Times;
00072 int mTries;
00073 volatile NATDetectServer::Reply mReply;
00074 XPAddress mAddress1;
00075 XPAddress mAddress2;
00076
00077 XPAddress mAddress1Reply;
00078 XPAddress mAddress2Reply;
00079
00080 bool mIsNiceNAT;
00081
00082 bool mGotOther;
00083 bool mServerAddressSet;
00084 };
00085
00086 }
00087
00088 }
00089
00090 #endif