Author Topic: Weird TNManager.Ping Issue  (Read 330 times)

Doomlazy

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 1
  • Posts: 28
    • View Profile
Weird TNManager.Ping Issue
« on: January 27, 2018, 04:28:14 PM »
I was trying to get TNManager.Ping setup so I could display the player's ping to the gameserver.
I was able to successfully Ping my UdpLobbyServer with its IP and port but if I tried to ping the actual gameserver the callback was never called.
The problem is in TNGameClient, case Packet.ResponsePing.
The "ip" variable is null for some reason so my callback would not get called.
I got the gameserver ping working but I had to ignore the is "ip" null check and remove IpEndPoint ipAddress from GameClient.OnPing.
Is there going to be any problems with this solution and can anyone tell me why the "ip" was always null after pinging my gameserver?

Here is the edited TNGameClient code:
  1. public delegate void OnPing (int milliSeconds);

  1. case Packet.ResponsePing:
  2. {
  3.     int ping = (int)(mMyTime - mPingTime);
  4.  
  5.     if (onPing != null) {
  6.         onPing(ping);
  7.     } else {
  8.        mCanPing = true;
  9.        mPing = ping;
  10.     }
  11.     break;
  12. }
« Last Edit: January 27, 2018, 04:35:46 PM by Doomlazy »

Doomlazy

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 1
  • Posts: 28
    • View Profile
Re: Weird TNManager.Ping Issue
« Reply #1 on: January 28, 2018, 11:27:48 AM »
Never mind I realised TNManager.Ping is for remote servers and I can just use TNManager.ping for the current game server.