00001 /* START_LICENSE_HEADER 00002 00003 Copyright (C) 2000 Martin Piper, original design and program code 00004 Copyright (C) 2001 Replica Software 00005 00006 This program file is copyright (C) Replica Software and can only be used under license. 00007 For more information visit: http://www.replicanet.com/ 00008 Or email: info@replicanet.com 00009 00010 END_LICENSE_HEADER */ 00011 #ifndef __TRANSPORTNATUDP_H__ 00012 #define __TRANSPORTNATUDP_H__ 00013 #include "RNPlatform/Inc/DLLExportAPI.h" 00014 #include "RNXPURL/Inc/Transport.h" 00015 #include "RNXPSockets/Inc/XPSocket.h" 00016 00017 namespace RNReplicaNet 00018 { 00019 00020 namespace RNLobby 00021 { 00022 00028 class TransportNATUDP : public Transport 00029 { 00030 public: 00034 TransportNATUDP(); 00035 00039 virtual ~TransportNATUDP(); 00040 00041 // Optional implementation of Transport virtual functions. 00042 int GetPacketsSent(const bool reset); 00043 00044 int GetPacketsSentMerged(const bool reset); 00045 00046 int GetPacketsSentSize(const bool reset); 00047 00048 int GetPacketsReceived(const bool reset); 00049 00050 int GetPacketsReceivedMerged(const bool reset); 00051 00052 int GetPacketsReceivedSize(const bool reset); 00053 00054 int GetPacketsLost(const bool reset); 00055 00056 void SetBandwidthLimit(const Bandwidth enable); 00057 00058 Bandwidth GetBandwidthLimit(); 00059 00060 void SetMaximumOutputBandwidth(const int bytesPerSecond); 00061 00062 int GetMaximumOutputBandwidth(void); 00063 00064 void SetMaximumInputBandwidth(const int bytesPerSecond); 00065 00066 int GetMaximumInputBandwidth(void); 00067 00068 std::string GetPeerURL(void); 00069 00070 bool GetTransportClosed(void); 00071 00072 void SetEnableLANDiscovery(const bool enable); 00073 00074 bool GetEnableLANDiscovery(void); 00075 00076 // These pure virtual functions are the minimum feature set the transport has to support. 00077 00078 std::string CanAccept(void); 00079 00080 std::string CanRoute(void); 00081 00082 std::string ExportURL(void); 00083 00084 Transport *Allocate(void); 00085 00086 Error Listen(const int channel); 00087 00088 Error Connect(const std::string address); 00089 00090 Transport *Accept(void); 00091 00092 Error Send(const char *data,const int len); 00093 00094 Error SendReliable(const char *data,const int len,const unsigned int band = 0); 00095 00096 Error SendCertain(const char *data,const int len); 00097 00098 int Recv(char *const data,const int maxlen); 00099 00100 int GetMaxPacketSize(void); 00101 00102 std::string HandleDiscovery(void); 00103 00104 void HandleDiscoveryReply(const std::string reply); 00105 00106 void BeginDiscovery(void); 00107 00108 std::string GetNextDiscovery(void); 00109 00110 Error GetStatus(void); 00111 00112 void SetBaseTransport(Transport *baseTransport); 00113 00114 // Extension API for this transport type. Normally this wouldn't need to be used. 00119 bool SetNATValues(const bool isAdvertised,const int globalID,const int sessionID); 00120 void GetNATValues(bool &isAdvertised,int &globalID,int &sessionID); 00121 00124 static void SetServer(const XPAddress &address); 00126 static void ClearServer(void); 00127 00128 00129 private: 00130 friend class MyNATResolver; 00131 void SetError(void); 00132 00133 bool mAllocated; 00134 Transport *mBaseTransport; 00135 bool mIsResolved; 00136 int mMyNOnceUsed; 00137 bool mKnowExternalAddress; 00138 XPAddress mExternalAddress; 00139 bool mIsListen; 00140 bool mIsUsed; 00141 00142 bool mStateIsAdvertised; 00143 int mStateGlobalID; 00144 int mStateSessionID; 00145 }; 00146 00147 } // namespace RNLobby 00148 00149 } // namespace RNReplicaNet 00150 00151 #endif
1.5.3