# RakNet::Router2 Class Reference
[Router2]

Class interface for the Router2 system. More...

`#include <Router2.h>`

Inheritance diagram for RakNet::Router2:

List of all members.

## Public Member Functions
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 (SystemAddress systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual void | OnFailedConnectionAttempt (Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason)
virtual void | OnRakPeerShutdown (void)
| Called when RakPeer is shutdown.

## 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 | ( | 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]` | systemAddress | The system whose connection was closed
  `[in]` | rakNetGuid | The guid of the specified system
  `[in]` | lostConnectionReason | How the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from PluginInterface2.

virtual void RakNet::Router2::OnFailedConnectionAttempt | ( | Packet * | packet,
|  | PI2_FailedConnectionAttemptReason | failedConnectionAttemptReason |
| ) |  |  | `[virtual]`

Called when a connection attempt fails

Parameters:

  `[in]` | packet | Packet to be returned to the user
  `[in]` | failedConnectionReason | Why the connection failed

Reimplemented from PluginInterface2.

virtual PluginReceiveResult RakNet::Router2::OnReceive | ( | Packet * | packet | ) | `[virtual]`

OnReceive is called for every packet.

Parameters:

  `[in]` | packet | the 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 PluginInterface2.

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

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

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

- d:/RakNet-3.x/Source/Router2.h