Exemple #1
0
int main(void)
{
  cometd			*cometd = cometd_new();
  JsonNode			*connect = json_node_new(JSON_NODE_OBJECT);
  
  /*After the new you can enable or disable the Websocket simply do this, disabled by defautl*/
  cometd->config->webSockState = true;
  
  
  if (cometd->config->webSockState)
    return(webSocketTest());
  
  cometd_configure(cometd, COMETDOPT_URL, "http://m.zpush.ovh:8080/str/strd");
  cometd_configure(cometd, COMETDOPT_MAX_BACKOFF, 5000);
  struct _cometd_ext* logger = cometd_ext_logger_new();
  cometd_ext_add(&cometd->exts, logger);
  cometd_connect(cometd);
  connect = cometd_msg_connect_new(cometd);
  cometd_transport_send(cometd, connect);


  //cometd_subscribe(cometd, "/service/GmY-HuzW/6sd0/echo", handler);
  cometd_transport_send(cometd, cometd_ping_ls(cometd, "/service/GmY-HuzW/6sd0/echo"));
  //cometd_subscribe(cometd, "/service/GmY-HuzW/6sd0/ls", handler);
  //cometd_subscribe(cometd, "service/GmY-HuzW/6sd0/updateMeta", handler);
  //cometd_subscribe(cometd, "/service/GmY-HuzW/6sd0/ls", handler);
  //cometd_subscribe(cometd, "/service/GmY-HuzW/6sd0/newFile", handler);

  
  cometd_listen(cometd);
  return 0;
}
static void setup (void)
{
    log_clear();
    test_transport_recv_calls = 0;
    test_transport_send_calls = 0;

    g_instance = cometd_new();
    cometd_configure(g_instance, COMETDOPT_URL, TEST_SERVER_URL);
}
Exemple #3
0
END_TEST

START_TEST (test_cometd_msg_bad_connect_new)
{
  cometd* h = cometd_new();
  cometd_conn* conn = h->conn;

  cometd_conn_set_client_id(conn, "testid");
  cometd_conn_set_transport(conn, &TEST_TRANSPORT);

  JsonNode* msg   = cometd_msg_bad_connect_new(h);
  JsonObject* obj = json_node_get_object(msg);

  const gboolean successful = json_object_get_boolean_member(obj, COMETD_MSG_SUCCESSFUL_FIELD);
  fail_if(successful);
  
  json_node_free(msg);
  cometd_destroy(h);
}
Exemple #4
0
END_TEST

START_TEST (test_cometd_msg_connect_new)
{
  cometd* h = cometd_new();
  cometd_conn* conn = h->conn;

  cometd_conn_set_client_id(conn, "testid");
  cometd_conn_set_transport(conn, &TEST_TRANSPORT);

  JsonNode* msg   = cometd_msg_connect_new(h);
  JsonObject* obj = json_node_get_object(msg);

  const gchar* channel = json_object_get_string_member(obj, COMETD_MSG_CHANNEL_FIELD);
  fail_unless(strcmp(channel, COMETD_CHANNEL_META_CONNECT) == 0);

  json_node_free(msg);
  cometd_destroy(h);
}