Any way to check if game player is connected to internet


#1

I want to load a specific scene if user is connected to internet and load a specific scene if user is not connected to internet


#2

How about some jsscript (idk your network setup so i dont gaurantee if this works for u )

1.) => At beggining of the scene

    // get scenevariable 
	var amIOnline = runtimeScene.getVariables().get("mystatus");

	function checkServer(url, timeout) {
	  const controller = new AbortController();
	  const signal = controller.signal;
	  const options = { mode: 'no-cors', signal };
	  return fetch(url, options)
		.then(setTimeout(() => { controller.abort() }, timeout))
		.then(response =>
		  // if successful you are online else 
		  amIOnline.setString("online")   
		).catch(error => 
		  // walang internet :-(
		  amIOnline.setString("offline")
		);
	}
	checkServer("sample-url-to-check",2000);

2.) => Then compare the value of scenevariable ‘mystatus’ to be able to ChangeScenes

I only test this on my browser. It’s hard to check for internet connection even a simple window.navigator.onLine not effective in some situation… :-/

also take a look at CORS


#3

There is an extension for checking that.


#4

Tell me Name of that extension


#5

#6

Can u tell me how to use it for check internet availibliyy


#7

You just use the condition Is Online?