#1 2019-02-11 08:38:30

Daniel
Member
Registered: 2016-12-08
Posts: 23

WebSocket Server detecting disconnected clients without sessions ?

I using Mormot in scenario similar to the chat demo 31. Clients send messages and Server should send it to all other clients.

So when server receives a message it iterates a list of connected clients and sends the message to all except client which sent it.

I don't use authentication, and so SessionClosed is not called, is there another way to detect when a client has disconnected ?

Offline

#2 2019-02-11 09:46:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: WebSocket Server detecting disconnected clients without sessions ?

Usually, the disconnection frame opcode is supplied to the WebSockets event handler.

But if the client is not shutdown properly and doesn't send its "connection close" frame, then there is no such event... unless the server tries to send something to the client and there is a low-level socket error.

So you have to handle both cases.

Offline

Board footer

Powered by FluxBB