Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
Websocket API Send message when onClose is called

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

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!