Router2 Overview

Send messages through intermediate systems

Games often have a need to send to remote systems through an intermediate system, where the intermediate system itself does not act upon the data. That is to say, the intermediate system is just a relay. To make this easier, the Router2 plugin will do this automatically.

To use

Attach one instance of the Router2 plugin to each system..

Call EstablishRouting with the RakNetGUID of the destination system.

A message will be broadcast to all connected instances of RakPeer. For each of those that are running the Router2 plugin, the connection list will be queried to see who, if anyone is connected to the target system.

After all systems are queried, the system with the lowest total ping, that is also already forwarding the fewest connections, will start the UDPForwarder system and return ID_ROUTER_2_FORWARDING_ESTABLISHED. If no path is available, ID_ROUTER_2_FORWARDING_NO_PATH will be returned instead.

Once a path is established, you should attempt to connect to the target system as usual. The following code should be used:

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 that rerouting happens automatically. When a connection is rerouted, you will get ID_ROUTER_2_REROUTED. While the SystemAddress will have changed, the RakNetGUID will not. Therefore, you must only refer to the target system using RakNetGUID when using this plugin.

See Also

Index