[noPoll] nopoll_conn_set_on_ready don't work as expected
Elmar Sieke
elmar.sieke en gmx.net
Lun Feb 13 19:52:39 CET 2017
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_con
n_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 muchElmar
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_ga0b31b7e0694d6546
> 63b49ecaf82c0776.html#ga0b31b7e0694d654663b49ecaf82c0776
>
>
>
> Also, checkout the following links for fully working and complete
> examples:
>
>
>
> https://github.com/ASPLes/nopoll/blob/master/test/nopoll-regression-c
> lient.c
>
> https://github.com/ASPLes/nopoll/blob/master/test/nopoll-regression-l
> istener.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
> >
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.aspl.es/pipermail/nopoll/attachments/20170213/6384cc94/attachment.html>
Más información sobre la lista de distribución noPoll