[noPoll] nopoll_conn_set_on_ready don't work as expected

Elmar Sieke elmar.sieke en gmx.net
Lun Feb 6 21:56:52 CET 2017


Hello everyone,
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);

  // now call to wait for the loop to notify events
  nopoll_loop_wait (ctx, 0);
  }

Thanks  
Elmar


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