ReplicaNet and RNLobby  1
Public Member Functions | Static Public Member Functions | List of all members
XPURL Class Reference

#include <XPURL.h>

Inheritance diagram for XPURL:
Inheritance graph
[legend]

Public Member Functions

 XPURL ()
 
virtual ~XPURL ()
 
void BeginEnumerateTransports (void)
 
TransportEnumerateTransports (void)
 
std::string ParseURLs (const std::string urls)
 
void Poll (void)
 
void SetManualPoll (void)
 
void SetAutomaticPoll (void)
 

Static Public Member Functions

static void RegisterTransport (Transport &transport)
 
static void RegisterDefaultTransports (void)
 
static TransportFindTransport (const std::string url)
 
static bool FreeTransport (Transport *transport)
 
static void InitialiseNetwork (const bool hardware=false)
 
static void ShutdownNetwork (const bool hardware=false)
 
static DebugHandlerRegisterDebugHandler (DebugHandler *debugHandler=0)
 
static DebugHandlerGetDebugHandler (void)
 

Detailed Description

XPURL decodes and encodes URLs and acts as a common method for interfacing various networking protocols.

Constructor & Destructor Documentation

XPURL ( )

The ctor for an XPURL

virtual ~XPURL ( )
virtual

The dtor for an XPURL This cleans up everything for this class

Member Function Documentation

void BeginEnumerateTransports ( void  )

Starts enumerating the current number of Transport types

Transport* EnumerateTransports ( void  )

Enumerates the Transport list, BeginEnumerateTransports() must be called before this function Call this function repeatedly in a loop to enumerate through the list

Returns
the next Transport pointer in the list
static Transport* FindTransport ( const std::string  url)
static

Finds the matching Transport for the URL

Returns
The new Transport pointer for which Allocate() should be called to create a usable Transport pointer
static bool FreeTransport ( Transport transport)
static

Frees any resources for a Transport* returned by FindTransport()->Allocate();

static DebugHandler* GetDebugHandler ( void  )
static

Returns the debug handler set by RegisterDebugHandler() or null.

Returns
The debug handler or null if no debugger handler is registered.
static void InitialiseNetwork ( const bool  hardware = false)
static

Causes the network layer to start. This can include all system level hardware on the target platform.

Parameters
hardwareSet this to be true to initialise all network hardware. The default is false. It is not necessary to manually call this since the network will start automatically when the first network related function is used.
std::string ParseURLs ( const std::string  urls)

Parses a URL and after each iteration returns a tokenised URL. The first time this function is called pass in the whole URL and on subsequent calls pass in ""

Returns
Each iteration returns a single URL or "" to denote an end to the list of URLs
void Poll ( void  )

This polls XPURL. Normally an application will yield enough time during threads for XPURL to function. Sometimes an application that uses a lot of 3D graphics can lock out other threads for quite some time. In these cases you may call XPURL::Poll() to yield some time to XPURL to perform housekeeping. If a reliable UDP transport is being used this function will also poll the reliable UDP manager.
Single threaded considerations:
When using the single threaded libraries this method should be called regularly. Unless XPSession::Poll() or ReplicaNet::Poll() is called in which case the default action is that this Poll() method is called.

static DebugHandler* RegisterDebugHandler ( DebugHandler debugHandler = 0)
static

This registers an extensible debug handler for use by XPURL, XPSession, ReplicaNet and the Visual Debugger. A PlatformHeap::ForceFree() will delete the active currently registered DebugHandler class. The application can use RegisterDebugHandler() without a parameter to unregister the DebugHandler and avoid the handler being automatically freed by PlatformHeap::ForceFree().

Parameters
debugHandlerA pointer to an instance of the debug handler class. The default value is null which disables the debugger output.
Returns
The previous debug handler pointer or null if no debugger handler was registered.
static void RegisterDefaultTransports ( void  )
static

This static member function registers all of the default transports such as reliable UDP.

static void RegisterTransport ( Transport transport)
static

Registers a Transport pointer with the URL decoder

Parameters
transportthe Transport to register
void SetAutomaticPoll ( void  )

Sets the automatic Poll() method for this class and the reliable UDP manager.
In multi-threading libraries this restarts the automatic polling thread so that an application does not need the call Poll()
In single-threading libraries this method has no effect and does not start a thread.
The default multi-threading library behaviour is to enable multi-threading automatic polls,
The default single-threading library behaviour is to use manual polls,

void SetManualPoll ( void  )

Sets the manual Poll() method for this class and the reliable UDP manager.
For multi-threaded libraries this turns off the automatic polling method.
This allows an application to time exactly when polls are done.
The application must call Poll() on a regular basis. A good place is just before or after the frame update is done.

static void ShutdownNetwork ( const bool  hardware = false)
static

Forces the network layer to shutdown if it is started. This can include all system level hardware on the target platform. This should only be used after users of XPURL classes, such as XPSession and ReplicaNet, have been freed. This does not free all internal allocated memory blocks, an example would be for registered factory classes. To force all internal allocated memory to be released RNReplicaNet::PlatformHeap::ForceFree() should be called. A PlatformHeap::ForceFree() will call ShutdownNetwork(true).

Parameters
hardwareSet this to be true to shutdown all network hardware. The default is false.