So I am kinda losing my head rn, since I just can't find a way of broadcasting/sending a msg to all other clients whenever someone disconnects.
Any help would be appreciated.
var socket = new WebSocket( "ws://localhost:8080" );
socket.onopen = ( e ) => {
socket.send( JSON.stringify({ "userconnection": true }) );
}
socket.onmessage = ( e ) => {
console.log( e.data );
}
socket.onclose = ( e ) => {
socket.send( JSON.stringify({ "userdisconnect": true }) );
}
As I read it in socket.io it is possible to emit a message on connect and disconnect is it possible with WebSocket API js