<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">hi there,<div><br></div><div>for that I am using code like this:</div><div><br></div><div>btw: I added an issue to integrate some getters needed for that (i can create a pull-request if desired)</div><div><a href="https://github.com/warmcat/libwebsockets/issues/56">https://github.com/warmcat/libwebsockets/issues/56</a></div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">      </span>libwebsockets_set_onclose_callback(context, onclose_callback);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(187, 44, 162);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">     </span></span>while<span style="color: #000000"> (</span>true<span style="color: #000000">)</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">    </span>{</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                </span><span style="color: #bb2ca2">if</span> (_notificationsInQueue)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">             </span>{</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                        </span>_notificationsInQueue = <span style="color: #bb2ca2">false</span>;</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><span class="Apple-tab-span" style="white-space:pre">                 </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                      </span><span style="color: #bb2ca2">for</span> (<span style="color: #bb2ca2">int</span> i = libwebsockets_get_fd_count(context) - <span style="color: #272ad8">1</span>; i >= <span style="color: #272ad8">0</span>; i--)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                    </span>{</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                                </span><span style="color: #bb2ca2">struct</span> libwebsocket *tmpWsi = libwebsockets_get_wsi_at_index(context, i);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                              </span><span style="color: #bb2ca2">if</span> (tmpWsi)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                            </span>{</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                                        </span><span style="color: #bb2ca2">if</span> (libwebsockets_get_protocol(tmpWsi) == &protocols[<span style="color: #272ad8">0</span>])</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                                 </span>{</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                                                </span>PushNotificationSessionInfo *sessionInfo = (PushNotificationSessionInfo *)libwebsockets_get_user_space(tmpWsi);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                                          </span><span style="color: #bb2ca2">if</span> (sessionInfo && sessionInfo->sendPushNotification)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                                               </span>{</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                                                        </span>libwebsocket_callback_on_writable(context, tmpWsi);</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><span class="Apple-tab-span" style="white-space:pre">                                                      </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                                                      </span>sessionInfo->sendPushNotification = <span style="color: #bb2ca2">false</span>;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                                          </span>}</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                                        </span>}</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                                </span>}</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><span class="Apple-tab-span" style="white-space:pre">                </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">              </span><span style="color: #bb2ca2">if</span> (libwebsocket_service(context, <span style="color: #272ad8">100</span>) != <span style="color: #272ad8">0</span>)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">               </span>{</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(209, 47, 27);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">                  </span>lwsl_err(</span>"libwebsocket_service not 0!\n"<span style="color: #000000">);</span></div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><span class="Apple-tab-span" style="white-space:pre">                      </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(187, 44, 162);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">                       </span></span>break<span style="color: #000000">;</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">            </span>}</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div><div>Am 04.02.2014 um 15:28 schrieb Sergio Vasquez <<a href="mailto:andy.green@linaro.org">andy.green@linaro.org</a>>:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>Hello,</div><div><br></div><div>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.</div>
<div>My problem is that the threads where the server code is executing must return and my wsi (struct libwebsocket parameter) cannot be saved.</div><div>I manage to save the context but I do not know how to push data just with that. Do you have any ideas?</div>
<div><br></div><div>Regards,</div><div>Sergio Vasquez</div></div>
_______________________________________________<br>Libwebsockets mailing list<br><a href="mailto:Libwebsockets@ml.libwebsockets.org">Libwebsockets@ml.libwebsockets.org</a><br>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets<br></blockquote></div><br></div></body></html>