[noPoll] nopoll_conn_set_on_ready don't work as expected

Elmar Sieke elmar.sieke en gmx.net
Lun Feb 13 21:25:13 CET 2017


Hello Francis,good news! Thank you for the library :) Great 
On Mon, 2017-02-13 at 20:18 +0100, Francis Brosnan Blázquez wrote:
> Sorry Elmar, I missed an important piece..thanks for reporting! :-)
> 
> Best Regards,
> 
> 
> 
> >     Hello Elmar,
> > 
> >     
> > 
> >     Certainly you have found a bug. I've updated noPoll's source
> > code to
> > 
> >     allow defining on_ready handlers at client side...which will be
> > called
> > 
> >     once handshake is completed.
> > 
> >     
> > 
> >     https://github.com/ASPLes/nopoll/commit/f1d3f5151c176f0f6af80cf
> > 671cbf611c2605d4c
> > 
> >     
> > 
> >     We should be close to release next stable release (I hope this
> > week),
> > 
> >     Best Regards,
> > 
> >     
> > 
> >     
> > > Hello Francis,
> > > 
> > > according to your answer I have still one question. The debug
> > > output shows that the connection handshake was done without
> > > error. 
> > > In this case the equivalent listener function fired on_ready. The
> > > client function doesn't.
> > > 
> > > nopoll_conn.c:
> > > nopoll_conn_complete_handshake_check_listener()
> > > nopoll_conn_complete_handshake_check_client()
> > > 
> > > Is this behavior desired? Or should the client function also
> > > fired on_ready?
> > > 
> > > debug output:
> > > (proc 22914): (debug)nopoll_conn.c:2655 Sec-Websocket-Accept
> > > matches expected
> > > value..nopoll_conn_complete_handshake_check_client (0x1d71420,
> > > 0x1d72380)=1
> > > 
> > > Thank you so much
> > > Elmar
> > > 
> > > 
> > >         On Sun, 2017-02-12 at 13:47 +0100, Francis Brosnan
> > > Blázquez wrote:
> > > 
> > >         
> > > >             
> > > > 
> > > >             
> > > > > Hello everyone,
> > > > > 
> > > > >             
> > > > 
> > > >             
> > > > 
> > > >             Hello Elmar,
> > > > 
> > > >             
> > > > 
> > > >             
> > > > > I have just started to use nopoll as client application. I
> > > > > run the
> > > > > basic WebSocket client example successfully. 
> > > > > I tried to use nopoll_conn_set_on_ready() instead of
> > > > > nopoll_conn_wait_until_connection_ready(). But my on_ready
> > > > > call back
> > > > > never appears. Did I misunderstand something? Here is my
> > > > > code:
> > > > > 
> > > > > #include <stdio.h>
> > > > > #include <nopoll.h>
> > > > > 
> > > > > nopoll_bool on_ready(noPollCtx *ctx, noPollConn *conn,
> > > > > noPollPtr
> > > > > user_data){
> > > > >   // send a message
> > > > >   printf("I'm ready!\n");
> > > > >   return nopoll_true;
> > > > > }
> > > > > 
> > > > > int
> > > > > main (int   argc,
> > > > >       char *argv[])
> > > > > {
> > > > >   noPollCtx * ctx = nopoll_ctx_new ();
> > > > >   if (! ctx) {
> > > > >       // error some handling code here
> > > > >   }
> > > > > 
> > > > >   nopoll_log_enable(ctx, nopoll_true);
> > > > > 
> > > > >   // call to create a connection
> > > > >   noPollConn * conn = nopoll_conn_new (ctx, "localhost",
> > > > > "8080", NULL,
> > > > > NULL, NULL, NULL);
> > > > >   if (! nopoll_conn_is_ok (conn)) {
> > > > >       // some error handling here
> > > > >   }
> > > > > 
> > > > >   // set ready handle
> > > > >   nopoll_conn_set_on_ready 	(conn, on_ready, NULL);
> > > > > 
> > > > >             
> > > > 
> > > >             
> > > > 
> > > >             Ok, on_ready function is not fired until it is not
> > > > fully established the connection.
> > > > 
> > > >             You'll have to send something or force negotiation
> > > > with something like
> > > > 
> > > >             this:
> > > > 
> > > >             
> > > > 
> > > >                      // block during 5 seconds until connection
> > > > is ready or timeout is reached
> > > > 
> > > >             nopoll_conn_wait_until_connection_ready (conn, 5);
> > > > 
> > > >             
> > > > 
> > > >             See relevant information at nopoll_conn_new
> > > > explaining more details about
> > > > 
> > > >             your question:
> > > > 
> > > >             
> > > > 
> > > >             http://www.aspl.es/nopoll/html/group__nopoll__conn_
> > > > ga0b31b7e0694d654663b49ecaf82c0776.html#ga0b31b7e0694d654663b49
> > > > ecaf82c0776
> > > > 
> > > >             
> > > > 
> > > >             Also, checkout the following links for fully
> > > > working and complete examples:
> > > > 
> > > >             
> > > > 
> > > >             https://github.com/ASPLes/nopoll/blob/master/test/n
> > > > opoll-regression-client.c
> > > > 
> > > >             https://github.com/ASPLes/nopoll/blob/master/test/n
> > > > opoll-regression-listener.c
> > > > 
> > > >             
> > > > 
> > > >             Best Regards,
> > > > 
> > > >             
> > > > 
> > > >             
> > > > 
> > > >             
> > > > >   // now call to wait for the loop to notify events
> > > > >   nopoll_loop_wait (ctx, 0);
> > > > >   }
> > > > > 
> > > > > Thanks  
> > > > > Elmar
> > > > > _______________________________________________
> > > > > noPoll mailing list
> > > > > noPoll at lists.aspl.es
> > > > > http://lists.aspl.es/cgi-bin/mailman/listinfo/nopoll
> > > > > 
> > > > >             
> > > > 
> > > >             
> > > > 
> > > >             
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > >         
> > > 
> > >     
> > 
> >     
> > 
> >     
> > 
> > 
> > _______________________________________________
> > noPoll mailing list
> > noPoll at lists.aspl.es
> > http://lists.aspl.es/cgi-bin/mailman/listinfo/nopoll
> > 
> > 
> > 
> > 
> > 
> 
> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.aspl.es/pipermail/nopoll/attachments/20170213/473995d7/attachment.html>


Más información sobre la lista de distribución noPoll