Salta al contenuto

Websocket: display users online, how to send message when clien disconnect

1

I am doing the function of displaying users who are online using websocket. I follow here: https://github.com/aws-samples/simple-websockets-chat-app I've done successfully. It will create 3 lambda function: onConnect, sendMess, onDisconnect. Receiving and sending messages to all clients is ok. If a user accesses the website, will send that user data(name, avatar..) to the server.

But I currently don't know how to handle connect and disconnect on the server with that data. How to send message from server to all client when a client disconnect. Hope you can teach me. Thank you very much.
(image - show users online) https://i.stack.imgur.com/h6e3Q.png

Edited by: Namlq on Nov 10, 2019 7:01 PM

posta 6 anni fa652 visualizzazioni
1 Risposta
0

I used onbeforeunload Event, so my problem resolved

con risposta 6 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.