1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-06-30 05:31:07 +02:00

Remove old JS

This commit is contained in:
Alexandre Iooss
2020-10-20 21:45:26 +02:00
parent 11231ceb84
commit c88f473ec0
7 changed files with 106 additions and 114 deletions

View File

@ -17,21 +17,18 @@ export class GsWebSocket {
* @param {Function} openCallback Function called when connection is established.
* @param {Function} closeCallback Function called when connection is lost.
*/
open(openCallback, closeCallback) {
open() {
this._open();
this.socket.addEventListener("open", (event) => {
this.socket.addEventListener("open", () => {
console.log("WebSocket opened");
openCallback(event);
});
this.socket.addEventListener("close", (event) => {
this.socket.addEventListener("close", () => {
console.log("WebSocket closed, retrying connection in 1s...");
setTimeout(this._open, 1000);
closeCallback(event);
});
this.socket.addEventListener("error", (event) => {
this.socket.addEventListener("error", () => {
console.log("WebSocket errored, retrying connection in 1s...");
setTimeout(this._open, 1000);
closeCallback(event);
});
}