Fix pages to only reload after a good connection
This commit is contained in:
parent
f9cf53debc
commit
8046f8ea95
|
@ -6,10 +6,13 @@ const nodes = {};
|
||||||
let socket = null;
|
let socket = null;
|
||||||
|
|
||||||
function ooui (rootElementPath) {
|
function ooui (rootElementPath) {
|
||||||
|
var opened = false;
|
||||||
|
|
||||||
socket = new WebSocket ("ws://" + document.location.host + rootElementPath, "ooui");
|
socket = new WebSocket ("ws://" + document.location.host + rootElementPath, "ooui");
|
||||||
|
|
||||||
socket.addEventListener ("open", function (event) {
|
socket.addEventListener ("open", function (event) {
|
||||||
console.log ("Web socket opened");
|
console.log ("Web socket opened");
|
||||||
|
opened = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.addEventListener ("error", function (event) {
|
socket.addEventListener ("error", function (event) {
|
||||||
|
@ -18,7 +21,9 @@ function ooui (rootElementPath) {
|
||||||
|
|
||||||
socket.addEventListener ("close", function (event) {
|
socket.addEventListener ("close", function (event) {
|
||||||
console.error ("Web socket close", event);
|
console.error ("Web socket close", event);
|
||||||
|
if (opened) {
|
||||||
location.reload ();
|
location.reload ();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.addEventListener("message", function (event) {
|
socket.addEventListener("message", function (event) {
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ooui
|
||||||
|
{
|
||||||
|
static class Platform
|
||||||
|
{
|
||||||
|
#if __IOS32423__
|
||||||
|
public static void Present (string url, object presenter)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public static void Present (string url, object presenter)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue