From 8046f8ea95300ce8a8c7952a04e6a70f441f993d Mon Sep 17 00:00:00 2001 From: "Frank A. Krueger" Date: Fri, 7 Jul 2017 16:57:38 -0700 Subject: [PATCH] Fix pages to only reload after a good connection --- Ooui/Client.js | 7 ++++++- Ooui/Platform.cs | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Ooui/Platform.cs diff --git a/Ooui/Client.js b/Ooui/Client.js index d9cf206..c28af38 100644 --- a/Ooui/Client.js +++ b/Ooui/Client.js @@ -6,10 +6,13 @@ const nodes = {}; let socket = null; function ooui (rootElementPath) { + var opened = false; + socket = new WebSocket ("ws://" + document.location.host + rootElementPath, "ooui"); socket.addEventListener ("open", function (event) { console.log ("Web socket opened"); + opened = true; }); socket.addEventListener ("error", function (event) { @@ -18,7 +21,9 @@ function ooui (rootElementPath) { socket.addEventListener ("close", function (event) { console.error ("Web socket close", event); - location.reload (); + if (opened) { + location.reload (); + } }); socket.addEventListener("message", function (event) { diff --git a/Ooui/Platform.cs b/Ooui/Platform.cs new file mode 100644 index 0000000..a784403 --- /dev/null +++ b/Ooui/Platform.cs @@ -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 + } +}