[Libwebsockets] regarding publish -subscribe using libwebsockets

Roger Light roger at atchoo.org
Sun Apr 24 09:33:32 CEST 2016


Hi Suman,

As Andy suggests you just need to think about the problem differently.
I use libwebsockets to provide WS support for my pub/sub server and
the WS clients just mix in with the TCP ones, they just don't call
read()/write() instead being handled by libwebsockets.

Cheers,

Roger


On Sun, Apr 24, 2016 at 7:02 AM, Suman.Patro-TRN
<Suman.Patro-TRN at lntebg.com> wrote:
> Hello,
>
>             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,
>
> Suman
>
> Larsen & Toubro Limited
>
> www.larsentoubro.com
>
> 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.
>
>
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://libwebsockets.org/mailman/listinfo/libwebsockets
>



More information about the Libwebsockets mailing list