#include <UDPProxyClient.h>
Public Member Functions | |
void | SetResultHandler (UDPProxyClientResultHandler *rh) |
bool | RequestForwarding (SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNetTimeMS timeoutOnNoDataMS, RakNet::BitStream *serverSelectionBitstream=0) |
virtual void | Update (void) |
Update is called every time a packet is checked for . | |
virtual PluginReceiveResult | OnReceive (Packet *packet) |
virtual void | OnShutdown (void) |
Called when RakPeer is shutdown. |
When NAT Punchthrough fails, it is possible to use a non-NAT system to forward messages from us to the recipient, and vice-versa The class to forward messages is UDPForwarder, and it is triggered over the network via the UDPProxyServer plugin. The UDPProxyClient connects to UDPProxyCoordinator to get a list of servers running UDPProxyServer, and the coordinator will relay our forwarding request
PluginReceiveResult UDPProxyClient::OnReceive | ( | Packet * | packet | ) | [virtual] |
OnReceive is called for every packet.
[in] | packet | the packet that is being returned to the user |
Reimplemented from PluginInterface2.
bool UDPProxyClient::RequestForwarding | ( | SystemAddress | proxyCoordinator, | |
SystemAddress | sourceAddress, | |||
SystemAddress | targetAddress, | |||
RakNetTimeMS | timeoutOnNoDataMS, | |||
RakNet::BitStream * | serverSelectionBitstream = 0 | |||
) |
Sends a request to proxyCoordinator to find a server and have that server setup UDPForwarder::StartForwarding() on our address to targetAddress The forwarded datagrams can be from any UDP source, not just RakNet
Systems running UDPProxyServer must be connected to proxyCoordinator and logged in via UDPProxyCoordinator::LoginServer() or UDPProxyServer::LoginToCoordinator()
RakNet's protocol will ensure a message is sent at least every 5 seconds, so if routing RakNet messages, it is a reasonable value for timeoutOnNoDataMS, plus an extra few seconds for latency.
[in] | proxyCoordinator | System we are connected to that is running the UDPProxyCoordinator plugin |
[in] | sourceAddress | External IP address of the system we want to forward messages from. This does not have to be our own system. To specify our own system, you can pass UNASSIGNED_SYSTEM_ADDRESS which the coordinator will treat as our external IP address. |
[in] | targetAddress | External IP address of the system we want to forward messages to. This system does NOT have to be connected or otherwise do anything. |
[in] | timeoutOnNoData | If no data is sent by the forwarded systems, how long before removing the forward entry from UDPForwarder? UDP_FORWARDER_MAXIMUM_TIMEOUT is the maximum value. Recommended high enough to not drop valid connections, but low enough to not waste forwarding slots on the proxy server. |
[in] | serverSelectionBitstream | If you want to send data to UDPProxyCoordinator::GetBestServer(), write it here |
void UDPProxyClient::SetResultHandler | ( | UDPProxyClientResultHandler * | rh | ) |
Receives the results of calling RequestForwarding() Set before calling RequestForwarding or you won't know what happened
[in] | resultHandler |