[Libwebsockets] Initiating a write to select clients

Tortoise Mailbox tortoise.mailbox at gmail.com
Sun Jan 31 04:34:14 CET 2016


Thanks guys,

I am going to stick with the event loop as shown in the test-server.c
sample program for now.  I will create my own list of wsi and user_data
pointers.  I will leave it single-threaded for the moment.  I will let you
know if I get stuck.

Thanks again,

On Sun, 31 Jan 2016 at 04:34 Bruce Perens <andy.green at linaro.org> wrote:

> I think the key is that you need to write your own event loop, rather than
> provide the one that Andy packages for us. Then, you have all of the data
> that you need.
>
> On Sat, Jan 30, 2016 at 4:42 AM, Andy Green <andy at warmcat.com> wrote:
>
>>
>>
>> On 01/30/2016 08:21 PM, Tortoise Mailbox wrote:
>>
>>> Hello,
>>>
>>> My websockets server will have a number of clients connected to it
>>> simultaneously.  Each client will be interested in different
>>> information.  The server will send data to the clients under 2
>>> conditions: periodic updates, or on detection changed data.  Different
>>> clients will request updates at different intervals e.g., a phone with
>>> limited bandwidth might request updates every 10 seconds, but a desktop
>>> browser might request updates every 1 second.  How do I initiate writing
>>> to select clients using libwebsockets?  I may be mistaken, but the
>>>
>>
>> LWS_VISIBLE LWS_EXTERN int
>> lws_callback_on_writable(struct lws *wsi);
>>
>> sample programs only show sending of data in response to receiving data,
>>> or sending data periodically to all clients (not specific clients).
>>> Also, is it possible to access the per-session data outside of the
>>> callback?
>>>
>>
>> These are all the same issue actually, you want to hold your own list of
>> wsi + user pointer (which you can acquire at ESTABLISHED callback and
>> retire at the corresponding CLOSE callback).
>>
>> If you look at the locking in the test-server-pthreads example, you can
>> use this to guarantee a wsi will not disappear from under you in a
>> different thread.  And it's safe to call lws_callback_on_writable()
>> otherwise from the other thread.
>>
>> -Andy
>>
>> Thank you.
>>>
>>>
>>> _______________________________________________
>>> Libwebsockets mailing list
>>> Libwebsockets at ml.libwebsockets.org
>>> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>>>
>>> _______________________________________________
>> Libwebsockets mailing list
>> Libwebsockets at ml.libwebsockets.org
>> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>>
>
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20160131/31e14af2/attachment-0001.html>


More information about the Libwebsockets mailing list