if (request == Packet.RequestActivateUDP)
{
int pid = reader.ReadInt32();
player = GetPlayer(pid);
// This message must arrive after RequestSetUDP which sets the UDP end point.
// We do an additional step here because in some cases UDP port can be changed
// by the router so that it appears that packets come from a different place.
if (player != null && player.udpEndPoint != null && player.udpEndPoint.Address == ip.Address)
{
player.udpEndPoint = ip;
player.udpIsUsable = true;
mUdp.SendEmptyPacket(player.udpEndPoint);
}
}
else if (request == Packet.RequestPing)
{
BeginSend(Packet.ResponsePing);
EndSend(ip);
}