[Libwebsockets] How to maintain a list of online clients ?

hanguofu hanguofu at 163.com
Mon Oct 24 17:57:55 CEST 2016

Hi , Andy :

Great ! I like this feature :)

Do you mean server application will be informed of the dropped connection at case LWS_CALLBACK_CLOSED if client is disconnected at the ping-pong interval ?

Please allow me to express my gratitude to your constant contribution to this great project !

Cheer !

Guofu Han

At 2016-10-24 00:08:03, "Andy Green" <andy at warmcat.com> wrote:
>On October 24, 2016 12:01:11 AM GMT+08:00, hanguofu <hanguofu at 163.com> wrote:
>>I thought this question had been asked before , but I still want to
>>confirm it :
>>I am developing  server and client applications with libwebsocket at
>>both sides.  I would like to maintain a list of all of the online
>>clients at the server side so that the server can talk to a  client
>>which has been silent and still online. Are LWS_CALLBACK_ESTABLISHED
>>and  LWS_CALLBACK_CLOSED enough to maintain such information ? Is tcp
>>keepalive a must  to achieve this goal ?
>If all you want to do is confirm every established ws client connection is still alive, lws can do it for you in v2.1 and later.  You can set this in the context creation info struct:
>unsigned short ws_ping_pong_interval;
>	/**< CONTEXT: 0 for none, else interval in seconds between sending
>	 * PINGs on idle websocket connections.  When the PING is sent,
>	 * the PONG must come within the normal timeout_secs timeout period
>	 * or the connection will be dropped.
>	 * Any RX or TX traffic on the connection restarts the interval timer,
>	 * so a connection which always sends or receives something at intervals
>	 * less than the interval given here will never send PINGs / expect
>	 * PONGs.  Conversely as soon as the ws connection is established, an
>	 * idle connection will do the PING / PONG roundtrip as soon as
>	 * ws_ping_pong_interval seconds has passed without traffic
>	 */
>>Regards !
>>Guofu Han   
>>Libwebsockets mailing list
>>Libwebsockets at ml.libwebsockets.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20161024/d93a8490/attachment-0001.html>

More information about the Libwebsockets mailing list