mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Receive messages from server
This commit is contained in:
parent
4c5a608531
commit
45b2bcda9c
@ -29,6 +29,11 @@ class UserWebSocket {
|
|||||||
this.ws.addEventListener("error", (e) => this.Error(e))
|
this.ws.addEventListener("error", (e) => this.Error(e))
|
||||||
this.ws.addEventListener("close", (e) => this.Closed(e));
|
this.ws.addEventListener("close", (e) => this.Closed(e));
|
||||||
|
|
||||||
|
// Handle incoming messages
|
||||||
|
this.ws.addEventListener("message", (e) => {
|
||||||
|
this.ProcessMessage(JSON.parse(e.data));
|
||||||
|
})
|
||||||
|
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
this.Error(e);
|
this.Error(e);
|
||||||
}
|
}
|
||||||
@ -74,4 +79,13 @@ class UserWebSocket {
|
|||||||
delete this.ws
|
delete this.ws
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process an incoming message
|
||||||
|
*
|
||||||
|
* @param {any} msg The incoming message
|
||||||
|
*/
|
||||||
|
static async ProcessMessage(msg) {
|
||||||
|
console.error("WS message", msg)
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user