[Libwebsockets] regarding publish -subscribe using libwebsockets

Suman.Patro-TRN Suman.Patro-TRN at lntebg.com
Sun Apr 24 08:02:55 CEST 2016


            I am trying to achieve publish -subscribe mechanism using libwebsockets.  I have a backend server (tcp) which has pub-sub logic.I have integrated my websocket server based on libwebsockets into the  backend server on different port to that of the tcp one. My goal is whenever a web client subscribes to a specific topic , it should fetch data that the tcp client (publisher) pushes based on the same  topic. This works fine for a single  web client. But I am stuck for a multiple clients scenario. The issue is as follows: Since publishing of data is not from the web client but from tcp client , so LWS SERVER WRITABLE could not be used to publish data. Hence I have written my own method in the websocket server to publish data using LWS_WRITE  for each  connection based on unique wsi pointer. But the problem that arises is whenever a new client comes in, I get a new wsi pointer and soon after LWS_CONNECTION _ESTABLISHED , the new client starts getting data without even subscribing for a topic and the older one stops getting data. My question is: how can I allow publishing of data only after LWS_RECEIVE(after subscription), Can there be any validation that can be done between LWS_CONNECTION_ESTABLISHED  and LWS_RECEIVE? Other design solutions are also welcome.

Please reply. Awaiting response.

Thanks and regards,


Larsen & Toubro Limited


This Email may contain confidential or privileged information for the intended recipient (s). If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20160424/81b2e477/attachment.html>

More information about the Libwebsockets mailing list