[Libwebsockets] Send messages to client from Server

SriHarsha mynameissriharsha at gmail.com
Thu Sep 25 08:56:44 CEST 2014

Thank you so much for the quick response.

So I guess the logic should be queue up the messages that need to be sent
and whenever you get a LWS_CALLBACK_SERVER_WRITEABLE you serialize the
messages and send them to the client ?

On Wed, Sep 24, 2014 at 11:51 PM, Andy Green <andy at warmcat.com> wrote:

> On 25 September 2014 14:46:39 GMT+08:00, SriHarsha <
> mynameissriharsha at gmail.com> wrote:
> >Hey Andy,
> >How are you ?
> >
> >I had a quick question about how to send messages from the server to
> >the
> >browser.
> >
> >Right now I am hoping when I receive a connection in my callback
> >I can store the pointer to the libWebSocket struct and use it later on.
> >
> >When I want to send the message from the server to my client I want to
> >use libwebsocket_write
> >and then pass the pointer that I had stored previous.
> >
> >Do you think this is a nice way to do it ?
> No, the library does not work like that.
> Look at the example apps and how they ask for a callback when the
> connection is writeable, and do any writing from that callback.
> You can keep a wsi by following the lifecycle callbacks, but unless you
> have another thread that wants it (and he is only allowed to ask for a
> callback when it is writeable), you do not need to.
> -Andy
> >Any help is greatly appreciated.
> >
> >Thank you,
> >H
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20140924/9564d61b/attachment-0001.html>

More information about the Libwebsockets mailing list