RakNet  4.0
Public Member Functions | List of all members
RakNet::Router2 Class Reference

Class interface for the Router2 system. More...

#include <Router2.h>

Inheritance diagram for RakNet::Router2:
RakNet::PluginInterface2

Public Member Functions

void SetSocketFamily (unsigned short _socketFamily)
 
void EstablishRouting (RakNetGUID endpointGuid)
 Query all connected systems to connect through them to a third system. System will return ID_ROUTER_2_FORWARDING_NO_PATH if unable to connect. Else you will get ID_ROUTER_2_FORWARDING_ESTABLISHED.
 
void SetMaximumForwardingRequests (int max)
 
void SetDebugInterface (Router2DebugInterface *_debugInterface)
 For testing and debugging.
 
Router2DebugInterface * GetDebugInterface (void) const
 Get the pointer passed to SetDebugInterface()
 
virtual PluginReceiveResult OnReceive (Packet *packet)
 
virtual void Update (void)
 Update is called every time a packet is checked for .
 
virtual void OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
 
virtual void OnFailedConnectionAttempt (Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason)
 
virtual void OnRakPeerShutdown (void)
 Called when RakPeer is shutdown.
 
- Public Member Functions inherited from RakNet::PluginInterface2
virtual void OnAttach (void)
 Called when the interface is attached.
 
virtual void OnDetach (void)
 Called when the interface is detached.
 
virtual void OnRakPeerStartup (void)
 Called when RakPeer is initialized.
 
virtual void OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
 
virtual bool UsesReliabilityLayer (void) const
 
virtual void OnDirectSocketSend (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
 
virtual void OnDirectSocketReceive (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
 
virtual void OnReliabilityLayerNotification (const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress, bool isError)
 
virtual void OnInternalPacket (InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time, int isSend)
 
virtual void OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time)
 
virtual void OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
 

Detailed Description

Class interface for the Router2 system.

Member Function Documentation

void RakNet::Router2::EstablishRouting ( RakNetGUID  endpointGuid)

Query all connected systems to connect through them to a third system. System will return ID_ROUTER_2_FORWARDING_NO_PATH if unable to connect. Else you will get ID_ROUTER_2_FORWARDING_ESTABLISHED.

On ID_ROUTER_2_FORWARDING_ESTABLISHED, EstablishRouting as follows:

RakNet::BitStream bs(packet->data, packet->length, false); bs.IgnoreBytes(sizeof(MessageID)); RakNetGUID endpointGuid; bs.Read(endpointGuid); unsigned short sourceToDestPort; bs.Read(sourceToDestPort); char ipAddressString[32]; packet->systemAddress.ToString(false, ipAddressString); rakPeerInterface->EstablishRouting(ipAddressString, sourceToDestPort, 0,0);

Note
The SystemAddress for a connection should not be used - always use RakNetGuid as the address can change at any time. When the address changes, you will get ID_ROUTER_2_REROUTED
virtual void RakNet::Router2::OnClosedConnection ( const SystemAddress systemAddress,
RakNetGUID  rakNetGUID,
PI2_LostConnectionReason  lostConnectionReason 
)
virtual

Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system

Parameters
[in]systemAddressThe system whose connection was closed
[in]rakNetGuidThe guid of the specified system
[in]lostConnectionReasonHow the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from RakNet::PluginInterface2.

virtual void RakNet::Router2::OnFailedConnectionAttempt ( Packet packet,
PI2_FailedConnectionAttemptReason  failedConnectionAttemptReason 
)
virtual

Called when a connection attempt fails

Parameters
[in]packetPacket to be returned to the user
[in]failedConnectionReasonWhy the connection failed

Reimplemented from RakNet::PluginInterface2.

virtual PluginReceiveResult RakNet::Router2::OnReceive ( Packet packet)
virtual

OnReceive is called for every packet.

Parameters
[in]packetthe packet that is being returned to the user
Returns
True to allow the game and other plugins to get this message, false to absorb it

Reimplemented from RakNet::PluginInterface2.

void RakNet::Router2::SetMaximumForwardingRequests ( int  max)

Set the maximum number of bidirectional connections this system will support Defaults to 0

void RakNet::Router2::SetSocketFamily ( unsigned short  _socketFamily)

Sets the socket family to use, either IPV4 or IPV6

Parameters
[in]socketFamilyFor IPV4, use AF_INET (default). For IPV6, use AF_INET6. To autoselect, use AF_UNSPEC.

The documentation for this class was generated from the following file: