Add basic offline handling to client.
This commit is contained in:
parent
cd6db8391b
commit
e47558d6d4
8
www/.js
8
www/.js
@ -82,23 +82,23 @@ let UI = {
|
||||
|
||||
function RECONNECT() {
|
||||
if(SOCKET === null) {
|
||||
console.log("Connecting..");
|
||||
console.log("Websocket connecting..");
|
||||
SOCKET = new WebSocket("wss://omen.kirisame.com:38612");
|
||||
SOCKET.binaryType = 'blob';
|
||||
SOCKET.addEventListener("error", (event) => {
|
||||
console.log("Failed: " + event.reason);
|
||||
SOCKET = null;
|
||||
LOAD(SCENES.Offline)
|
||||
});
|
||||
SOCKET.addEventListener("open", (event) => {
|
||||
if(SOCKET.readyState === WebSocket.OPEN) {
|
||||
console.log("Connected.");
|
||||
console.log("Websocket connected.");
|
||||
|
||||
SOCKET.addEventListener("message", (event) => {
|
||||
MESSAGE(event.data);
|
||||
});
|
||||
|
||||
SOCKET.addEventListener("close", (event) => {
|
||||
console.log("Closed (" + event.wasClean + ":" + event.code + "): " + event.reason);
|
||||
console.log("Websocket closed.");
|
||||
SOCKET = null;
|
||||
RECONNECT();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user