TransportNATUDP Class Reference

#include <TransportNATUDP.h>

Inheritance diagram for TransportNATUDP:

Inheritance graph
[legend]
Collaboration diagram for TransportNATUDP:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 TransportNATUDP ()
virtual ~TransportNATUDP ()
int GetPacketsSent (const bool reset)
int GetPacketsSentMerged (const bool reset)
int GetPacketsSentSize (const bool reset)
int GetPacketsReceived (const bool reset)
int GetPacketsReceivedMerged (const bool reset)
int GetPacketsReceivedSize (const bool reset)
int GetPacketsLost (const bool reset)
void SetBandwidthLimit (const Bandwidth enable)
Bandwidth GetBandwidthLimit ()
void SetMaximumOutputBandwidth (const int bytesPerSecond)
int GetMaximumOutputBandwidth (void)
void SetMaximumInputBandwidth (const int bytesPerSecond)
int GetMaximumInputBandwidth (void)
std::string GetPeerURL (void)
bool GetTransportClosed (void)
void SetEnableLANDiscovery (const bool enable)
bool GetEnableLANDiscovery (void)
std::string CanAccept (void)
std::string CanRoute (void)
std::string ExportURL (void)
TransportAllocate (void)
Error Listen (const int channel)
Error Connect (const std::string address)
TransportAccept (void)
Error Send (const char *data, const int len)
Error SendReliable (const char *data, const int len, const unsigned int band=0)
Error SendCertain (const char *data, const int len)
int Recv (char *const data, const int maxlen)
int GetMaxPacketSize (void)
std::string HandleDiscovery (void)
void HandleDiscoveryReply (const std::string reply)
void BeginDiscovery (void)
std::string GetNextDiscovery (void)
Error GetStatus (void)
void SetBaseTransport (Transport *baseTransport)
bool SetNATValues (const bool isAdvertised, const int globalID, const int sessionID)
void GetNATValues (bool &isAdvertised, int &globalID, int &sessionID)

Static Public Member Functions

static void SetServer (const XPAddress &address)
static void ClearServer (void)
 Clears any server set by SetServer().

Friends

class MyNATResolver


Detailed Description

A transport class for the NATUDP type of URL. Internally this extends the UDP URL.
The exported URL is encoded to contain NAT information required to find machines located anywhere on the local network or the internet using an external NATResolver server.

Constructor & Destructor Documentation

TransportNATUDP (  ) 

The ctor performs some basic initialisation

virtual ~TransportNATUDP (  )  [virtual]

The dtor makes sure everything is tidy


Member Function Documentation

int GetPacketsSent ( const bool  reset  )  [virtual]

Gets the total number of packets that were sent.

Parameters:
reset The default parameter for this function is false. If true then the value is returned as normal but the internal total is reset to zero
Returns:
Returns the total value, since the last reset to zero

Reimplemented from Transport.

int GetPacketsSentMerged ( const bool  reset  )  [virtual]

Gets the total number of merged packets that were sent.

Parameters:
reset The default parameter for this function is false. If true then the value is returned as normal but the internal total is reset to zero
Returns:
Returns the total value, since the last reset to zero

Reimplemented from Transport.

int GetPacketsSentSize ( const bool  reset  )  [virtual]

Gets the total size of packets that were sent.

Parameters:
reset The default parameter for this function is false. If true then the value is returned as normal but the internal total is reset to zero
Returns:
Returns the total value, since the last reset to zero

Reimplemented from Transport.

int GetPacketsReceived ( const bool  reset  )  [virtual]

Gets the total number of packets that were received.

Parameters:
reset The default parameter for this function is false. If true then the value is returned as normal but the internal total is reset to zero
Returns:
Returns the total value, since the last reset to zero

Reimplemented from Transport.

int GetPacketsReceivedMerged ( const bool  reset  )  [virtual]

Gets the total number of merged packets that were received.

Parameters:
reset The default parameter for this function is false. If true then the value is returned as normal but the internal total is reset to zero
Returns:
Returns the total value, since the last reset to zero

Reimplemented from Transport.

int GetPacketsReceivedSize ( const bool  reset  )  [virtual]

Gets the total size of packets that were received.

Parameters:
reset The default parameter for this function is false. If true then the value is returned as normal but the internal total is reset to zero
Returns:
Returns the total value, since the last reset to zero

Reimplemented from Transport.

int GetPacketsLost ( const bool  reset  )  [virtual]

Gets the total number of packets that were lost and had to be resent.

Parameters:
reset The default parameter for this function is false. If true then the value is returned as normal but the internal total is reset to zero
Returns:
Returns the total value, since the last reset to zero

Reimplemented from Transport.

void SetBandwidthLimit ( const Bandwidth  enable  )  [virtual]

Sets the bandwidth limit algorithm to be used for this Transport type.

Parameters:
enable The default parameter is kBandwidth_Off which disables any bandwidth limit for this Transport type. kBandwidth_Connection will turn on bandwidth calculation for each instance and connection using this Transport. For example, if there are five instances of this Transport type and kBandwidth_Connection is used with the maximum outgoing bandwidth to be 1000 bytes per second then the maximum combined bandwidth will capped to five times 1000 bytes per second, which is 5000 bytes per second.

Reimplemented from Transport.

Bandwidth GetBandwidthLimit (  )  [virtual]

Reads the configuration value set by SetBandwidthLimit()

Returns:
the configured value

Reimplemented from Transport.

void SetMaximumOutputBandwidth ( const int  bytesPerSecond  )  [virtual]

Sets the maximum output bandwidth for emulation.

Parameters:
bytesPerSecond the bandwidth in bytes per second. The default value is 0 meaning there is no limit.

Reimplemented from Transport.

int GetMaximumOutputBandwidth ( void   )  [virtual]

Reads the configuration value set by SetMaximumOutputBandwidth()

Returns:
the configured value

Reimplemented from Transport.

void SetMaximumInputBandwidth ( const int  bytesPerSecond  )  [virtual]

Sets the maximum input bandwidth for emulation.

Parameters:
bytesPerSecond the bandwidth in bytes per second. The default value is 0 meaning there is no limit.

Reimplemented from Transport.

int GetMaximumInputBandwidth ( void   )  [virtual]

Reads the configuration value set by GetMaximumInputBandwidth().

Returns:
the configured value.

Reimplemented from Transport.

std::string GetPeerURL ( void   )  [virtual]

If connected this gets the URL of the other transport. It is possible this function will return a null ("") string when connected if the transport provider does not support this functionality.

Returns:
the URL of the peer transport.

Reimplemented from Transport.

bool GetTransportClosed ( void   )  [virtual]

If this returns false the transport was closed due to an error such as a timeout. If this returns true then the transport was gracefully closed without an error. The default is to return false.

Reimplemented from Transport.

void SetEnableLANDiscovery ( const bool  enable  )  [virtual]

Enables or disables LAN discovery of this transport type.

Parameters:
enable Set this to be true to enable LAN discovery. False will disable LAN discovery. The default is true.

Reimplemented from Transport.

bool GetEnableLANDiscovery ( void   )  [virtual]

Reads the configuration value set by SetEnableLANDiscovery().

Returns:
the configured value.

Reimplemented from Transport.

std::string CanAccept ( void   )  [virtual]

Enables a Transport to state which type of protocol it can receive. Each protocol type is separated by a comma.

Returns:
the comma separated list of protocols supported by the Transport

Implements Transport.

std::string CanRoute ( void   )  [virtual]

Enables a Transport to state which type of protocol it can route. Each protocol type is separated by a comma.

Returns:
the comma separated list of protocols routed by the Transport

Implements Transport.

std::string ExportURL ( void   )  [virtual]

Exports a URL that is used by this transport and can be used by other Transports to locate this transport. The format of the URL follows this convention: <TransportType><data>/

Returns:
the URL to locate this transport

Implements Transport.

Transport* Allocate ( void   )  [virtual]

Used to allocate a transport of the relevant class type

Returns:
a Transport pointer

Implements Transport.

Error Listen ( const int  channel  )  [virtual]

Sets this Transport to listen on a certain channel. The default channel is defined as AnyGameChannel

Parameters:
channel the channel to listen on, for example DefaultGameChannel. This parameter need not be passed in, in which case AnyGameChannel is used.
Returns:
A Transport::Error is returned indicating success or failure for the operation

Implements Transport.

Error Connect ( const std::string  address  )  [virtual]

Tries to connect to a specified address

Parameters:
address the address to connect to
Returns:
A Transport::Error is returned indicating success or failure for the operation

Implements Transport.

Transport* Accept ( void   )  [virtual]

Accepts the first pending connection from another Transport

Returns:
returns NULL if there are no pending Transport connections or a new Transport pointer that can be used to communicate with

Implements Transport.

Error Send ( const char *  data,
const int  len 
) [virtual]

Tries to send data to the currently connected Transport via the "unreliable" method without using any form of packet loss correction.
This method of sending packets is very cheap since there is no packet loss correction. Before attempting to send any data using this transport instance wait for GetStatus() to return kTransport_EOK.

Parameters:
data the data to send
len the length of the data to send
Returns:
A Transport::Error is returned indicating success or failure for the operation

Implements Transport.

Error SendReliable ( const char *  data,
const int  len,
const unsigned int  band = 0 
) [virtual]

Tries to send data to the currently connected Transport via the "reliable" method that guarantees packets are received in the same order they are sent.
This method of sending packets is the most expensive in terms of CPU time and memory buffers Before attempting to send any data using this transport instance wait for GetStatus() to return kTransport_EOK.

Parameters:
data the data to send
len the length of the data to send
band This optional parameter allows the user to send reliable packets and ensure they are in original order grouped by band. This parameter is optional for a Transport to support and if supported the Transport may only support a limited number of bands.
Returns:
A Transport::Error is returned indicating success or failure for the operation

Implements Transport.

Error SendCertain ( const char *  data,
const int  len 
) [virtual]

Tries to send data to the currently connected Transport via the "certain" method that guarantees delivery of packets but does not gaurantee the packet receive order is maintained.
This method is less expensive than the "reliable" method because send and receive order is not preserved. Before attempting to send any data using this transport instance wait for GetStatus() to return kTransport_EOK.

Parameters:
data the data to send
len the length of the data to send
Returns:
A Transport::Error is returned indicating success or failure for the operation

Implements Transport.

int Recv ( char *const   data,
const int  maxlen 
) [virtual]

Tries to receive data pending at this Transport. Data packets received by this method are not merged together.

Parameters:
data the data buffer to use
maxlen the maximum length of this data buffer
Returns:
the length of the data received or zero for no data pending

Implements Transport.

int GetMaxPacketSize ( void   )  [virtual]

Gets the maximum packet size that can be transmitted over this Transport. The base spec requires a Transport to cope with packets of at least the number of bytes defined by TransportMinimumPacketSize

Returns:
the maximum packet size that can be transmitted

Implements Transport.

std::string HandleDiscovery ( void   )  [virtual]

If a discovery is pending this will return the URL of the source machine that made a discovery request

Returns:
returns the URL of the machine attempting a discovery or a "" string

Implements Transport.

void HandleDiscoveryReply ( const std::string  reply  )  [virtual]

This function handles the reply URL that is passed back to the previous calling machine of HandleDiscovery()

Parameters:
reply the reply string to send

Implements Transport.

void BeginDiscovery ( void   )  [virtual]

This starts the discovery cycle to try to find other transports

Implements Transport.

std::string GetNextDiscovery ( void   )  [virtual]

This is the function that can be used to discover other similar transports that can be connected to.

Returns:
Returns a URL, which is the URL passed in by HandleDiscoveryReply()

Implements Transport.

Error GetStatus ( void   )  [virtual]

Gets the status of this transport

Returns:
the status

Implements Transport.

bool SetNATValues ( const bool  isAdvertised,
const int  globalID,
const int  sessionID 
)

This sets the NAT values to be used for this transport instance. These values are set at construction time from the internal lobby state and may be changed at any time before Connect() or Listen() are used.

Returns:
Success returns true, failure returns false.

static void SetServer ( const XPAddress address  )  [static]

This sets the NATResolver server address for any NATUDP transports. This must be called before any NATUDP transports have been registered by RNLobby::RegisterDefaultTransports(). The default is to have no server set and therefore the default server is configured by the internal lobby state from any successful Backend verification. PlatformHeap::ForceFree() will also clear any server that has been set.


Generated on Sat Jun 28 22:02:35 2008 for ReplicaNet and RNLobby by  doxygen 1.5.3