Direkt zum Inhalt

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

gefragt vor 6 Jahren653 Aufrufe
1 Antwort
0

I used onbeforeunload Event, so my problem resolved

beantwortet vor 6 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.