[Libwebsockets] Libwebsockets push from the server problem

Gabriel Gritsch gabriel at gritsch-soft.com
Sat Feb 15 08:25:39 CET 2014


hi there,

for that I am using code like this:

btw: I added an issue to integrate some getters needed for that (i can create a pull-request if desired)
https://github.com/warmcat/libwebsockets/issues/56

	libwebsockets_set_onclose_callback(context, onclose_callback);

	while (true)
	{
		if (_notificationsInQueue)
		{
			_notificationsInQueue = false;
			
			for (int i = libwebsockets_get_fd_count(context) - 1; i >= 0; i--)
			{
				struct libwebsocket *tmpWsi = libwebsockets_get_wsi_at_index(context, i);
				if (tmpWsi)
				{
					if (libwebsockets_get_protocol(tmpWsi) == &protocols[0])
					{
						PushNotificationSessionInfo *sessionInfo = (PushNotificationSessionInfo *)libwebsockets_get_user_space(tmpWsi);
						if (sessionInfo && sessionInfo->sendPushNotification)
						{
							libwebsocket_callback_on_writable(context, tmpWsi);
							
							sessionInfo->sendPushNotification = false;
						}
					}
				}
			}
		}
		
		if (libwebsocket_service(context, 100) != 0)
		{
			lwsl_err("libwebsocket_service not 0!\n");
			
			break;
		}
	}


Am 04.02.2014 um 15:28 schrieb Sergio Vasquez <andy.green at linaro.org>:

> Hello,
> 
> I have almost finished my own server with libwebsockets-1.23-chrome32-firefox24, but there is a last subprotocol that I will need to implement. That protocol needs that the client establishes the connection and then wait for the server to push data within a certain frequency. During that time the client must just wait, it cannot send any message to the server.
> My problem is that the threads where the server code is executing must return and my wsi (struct libwebsocket parameter) cannot be saved.
> I manage to save the context but I do not know how to push data just with that. Do you have any ideas?
> 
> Regards,
> Sergio Vasquez
> _______________________________________________
> 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/20140215/3c7adb1c/attachment-0001.html>


More information about the Libwebsockets mailing list