{"action":"created","issue":{"url":"https://api.github.com/repos/warmcat/libwebsockets/issues/1205","repository_url":"https://api.github.com/repos/warmcat/libwebsockets","labels_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/1205/labels{/name}","comments_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/1205/comments","events_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/1205/events","html_url":"https://github.com/warmcat/libwebsockets/issues/1205","id":304169003,"number":1205,"title":"libwebsockets for sending server side events ","user":{"login":"vaghelan","id":803018,"avatar_url":"https://avatars0.githubusercontent.com/u/803018?v=4","gravatar_id":"","url":"https://api.github.com/users/vaghelan","html_url":"https://github.com/vaghelan","followers_url":"https://api.github.com/users/vaghelan/followers","following_url":"https://api.github.com/users/vaghelan/following{/other_user}","gists_url":"https://api.github.com/users/vaghelan/gists{/gist_id}","starred_url":"https://api.github.com/users/vaghelan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vaghelan/subscriptions","organizations_url":"https://api.github.com/users/vaghelan/orgs","repos_url":"https://api.github.com/users/vaghelan/repos","events_url":"https://api.github.com/users/vaghelan/events{/privacy}","received_events_url":"https://api.github.com/users/vaghelan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-03-11T15:51:42Z","updated_at":"2018-03-14T09:55:49Z","closed_at":"2018-03-14T09:55:49Z","author_association":"NONE","body":"Hi,\r\nI need to integrate libwebsockets for my application where it detects some IoT event and then it needs to push that event to client. Client just makes connection with server for subscription of notifications once and server needs to push event when it occurs. Client does not poll for event. If it needs to then it defeats the purpose of websocket. Since libwebsocket lib is single threaded and it has its own event loop and callback mechanism,  I was wondering how do I push event from a separate application thread. May be I need to have event loop as part of my app thread.\r\n\r\nHere are my thoughts : \r\n\r\nIf there are events then call - lws_callback_on_writable(wsi) so that callback is called with\r\nLWS_CALLBACK_SERVER_WRITEABLE reason code in callback. There I can push event. If more events left then I can keep interest ON - lws_callback_on_writable(wsi), otherwise no interest.\r\n\r\nWould this work ?\r\n\r\n----------MAIN EVENT LOOP CODE Integrated with app ----------\r\nwhile (n >= 0 && !interrupted)\r\n       // call app specific event generation code and get events in Q\r\n      // if events need to push then  enable write interest - lws_callback_on_writable(wsi);\r\n          n = lws_service(context, 1000);\r\n\r\n----------EVENT LOOP CODE ----------\r\n\r\nThanks\r\nNilesh."},"comment":{"url":"https://api.github.com/repos/warmcat/libwebsockets/issues/comments/372964710","html_url":"https://github.com/warmcat/libwebsockets/issues/1205#issuecomment-372964710","issue_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/1205","id":372964710,"user":{"login":"lws-team","id":15154525,"avatar_url":"https://avatars2.githubusercontent.com/u/15154525?v=4","gravatar_id":"","url":"https://api.github.com/users/lws-team","html_url":"https://github.com/lws-team","followers_url":"https://api.github.com/users/lws-team/followers","following_url":"https://api.github.com/users/lws-team/following{/other_user}","gists_url":"https://api.github.com/users/lws-team/gists{/gist_id}","starred_url":"https://api.github.com/users/lws-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lws-team/subscriptions","organizations_url":"https://api.github.com/users/lws-team/orgs","repos_url":"https://api.github.com/users/lws-team/repos","events_url":"https://api.github.com/users/lws-team/events{/privacy}","received_events_url":"https://api.github.com/users/lws-team/received_events","type":"User","site_admin":false},"created_at":"2018-03-14T09:55:49Z","updated_at":"2018-03-14T09:55:49Z","author_association":"OWNER","body":"You can find a ws[s] proxying example here\r\n\r\nhttps://github.com/warmcat/libwebsockets/tree/master/minimal-examples/minimal-ws-proxy"}}
{"actor":{"display_login":"lws-team"}}