[noPoll] nopoll_conn_set_on_ready don't work as expected

Francis Brosnan Blázquez francis.brosnan en aspl.es
Lun Feb 13 20:16:30 CET 2017


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/f1d3f5151c176f0f6af80cf671cbf611c2605d4c

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#ga0b31b7e0694d654663b49ecaf82c0776
> > 
> > Also, checkout the following links for fully working and complete
> > examples:
> > 
> > https://github.com/ASPLes/nopoll/blob/master/test/nopoll-regression-client.c
> > https://github.com/ASPLes/nopoll/blob/master/test/nopoll-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 en lists.aspl.es
> > > http://lists.aspl.es/cgi-bin/mailman/listinfo/nopoll
> > 
> > 
> > 


-- 
Francis Brosnan Blázquez  -  ASPL
http://www.asplhosting.com/
http://www.aspl.es/
https://twitter.com/aspl_es
https://twitter.com/asplhosting
https://twitter.com/francisbrosnanb
https://es.linkedin.com/in/francis-brosnan-blázquez-1353a218

91 134 14 22 - 91 134 14 45 - 91 116 07 57

AVISO LEGAL
 
En virtud de lo dispuesto en la Ley Orgánica 15/1999, de 13 de
diciembre, de Protección de Datos de Carácter Personal, le informamos de
que sus datos de carácter personal, recogidos de fuentes accesibles al
público o datos que usted nos ha facilitado previamente, proceden de
bases de datos propiedad de Advanced Software Production Line, S.L.
(ASPL).
 
ASPL garantiza que los datos serán tratados con la finalidad de mantener
las oportunas relaciones comerciales o promocionales con usted o la
entidad que usted representa. No obstante, usted puede ejercitar sus
derechos de acceso, rectificación, cancelación y oposición dispuestos en
la mencionada Ley Orgánica, notificándolo por escrito a ASPL -
Protección Datos, C/Antonio Suárez 10 A-102, 28802, Alcalá de Henares
(Madrid).

------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://lists.aspl.es/pipermail/nopoll/attachments/20170213/cd3c9a0b/attachment.html>


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