is it possible for client-sdk to get somehow ping time to the database? Thats important for us to know if some people have problems with connection to database(for example because of long distance in continent or strange NAT settings)
Best Answer
C
Customer Support
said
over 2 years ago
Hi Marcin,
Please have a look at the example here, which covers pinging the server, getting a roundtip time and syncing Gametime accross different time zones using Gamesparks Real Time Api.
-If you wish to ping an ip address of your choice from Unity:
sing UnityEngine; using System.Collections;
public class Check_InternetConnection : MonoBehaviour {
public bool isConnectedToInternet = false; public float maxTime = 2.0F; public float timeTaken = 0.0F;
Please have a look at the example here, which covers pinging the server, getting a roundtip time and syncing Gametime accross different time zones using Gamesparks Real Time Api.
-If you wish to ping an ip address of your choice from Unity:
sing UnityEngine; using System.Collections;
public class Check_InternetConnection : MonoBehaviour {
public bool isConnectedToInternet = false; public float maxTime = 2.0F; public float timeTaken = 0.0F;
Marcin Olszewski
Hello,
is it possible for client-sdk to get somehow ping time to the database? Thats important for us to know if some people have problems with connection to database(for example because of long distance in continent or strange NAT settings)
Hi Marcin,
Please have a look at the example here, which covers pinging the server, getting a roundtip time and syncing Gametime accross different time zones using Gamesparks Real Time Api.
-If you wish to ping an ip address of your choice from Unity:
sing UnityEngine;
using System.Collections;
public class Check_InternetConnection : MonoBehaviour {
public bool isConnectedToInternet = false;
public float maxTime = 2.0F;
public float timeTaken = 0.0F;
void Awake()
{
StartCoroutine("ConnectionTest");
}
IEnumerator ConnectionTest()
{
while (true)
{
yield return new WaitForSeconds(2f);// the interval between ping attempts
Ping testPing = new Ping("8.8.8.8");//Google - or Ip of your choice.
Debug.Log("Testing......" + testPing.ToString());
timeTaken = 0.0F;
while (!testPing.isDone)
{
timeTaken += Time.deltaTime;
if (timeTaken > maxTime)
{
// if time has exceeded the maxtime, break out and return false
isConnectedToInternet = false;
break;
}
yield return null;
}
if (timeTaken <= maxTime)
{
isConnectedToInternet = true;
}
yield return null;
}
}
}
Thanks,
-Dave.
Customer Support
Hi Marcin,
Please have a look at the example here, which covers pinging the server, getting a roundtip time and syncing Gametime accross different time zones using Gamesparks Real Time Api.
-If you wish to ping an ip address of your choice from Unity:
sing UnityEngine;
using System.Collections;
public class Check_InternetConnection : MonoBehaviour {
public bool isConnectedToInternet = false;
public float maxTime = 2.0F;
public float timeTaken = 0.0F;
void Awake()
{
StartCoroutine("ConnectionTest");
}
IEnumerator ConnectionTest()
{
while (true)
{
yield return new WaitForSeconds(2f);// the interval between ping attempts
Ping testPing = new Ping("8.8.8.8");//Google - or Ip of your choice.
Debug.Log("Testing......" + testPing.ToString());
timeTaken = 0.0F;
while (!testPing.isDone)
{
timeTaken += Time.deltaTime;
if (timeTaken > maxTime)
{
// if time has exceeded the maxtime, break out and return false
isConnectedToInternet = false;
break;
}
yield return null;
}
if (timeTaken <= maxTime)
{
isConnectedToInternet = true;
}
yield return null;
}
}
}
Thanks,
-Dave.
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2338 topics