fix: ListServer Ping not found in WebGL

This commit is contained in:
vis2k 2019-04-28 20:49:14 +02:00
parent 1764c1c9dd
commit 6c4b34ba06

View File

@ -18,8 +18,9 @@ public class ServerStatus
public ushort capacity;
public int lastLatency = -1;
#if !UNITY_WEBGL // Ping isn't known in WebGL builds
public Ping ping;
#endif
public ServerStatus(string ip, /*ushort port,*/ string title, ushort players, ushort capacity)
{
this.ip = ip;
@ -27,7 +28,9 @@ public ServerStatus(string ip, /*ushort port,*/ string title, ushort players, us
this.title = title;
this.players = players;
this.capacity = capacity;
#if !UNITY_WEBGL // Ping isn't known in WebGL builds
ping = new Ping(ip);
#endif
}
}
@ -201,6 +204,7 @@ void TickClient()
Debug.Log("[List Server] Client disconnected.");
}
#if !UNITY_WEBGL // Ping isn't known in WebGL builds
// ping again if previous ping finished
foreach (ServerStatus server in list.Values)
{
@ -210,6 +214,7 @@ void TickClient()
server.ping = new Ping(server.ip);
}
}
#endif
}
// otherwise try to connect
// (we may have just joined the menu/disconnect from game server)