END_TEST

START_TEST (test_cometd_process_connect_takes_advice_when_it_exists)
{
    cometd_conn* conn = g_instance->conn;
    cometd_conn_set_client_id(conn, "testid");
    cometd_conn_set_transport(conn, &TEST_TRANSPORT);

    // set advice
    JsonNode* msg = cometd_msg_connect_new(g_instance);
    cometd_advice* advice = cometd_advice_new();
    cometd_msg_set_advice(msg, advice);
    cometd_process_connect(g_instance, msg);

    // no advice
    JsonNode* bad_connect = cometd_msg_bad_connect_new(g_instance);
    cometd_process_connect(g_instance, bad_connect);

    // assert advice exists
    fail_unless(cometd_conn_advice(conn)->reconnect == COMETD_RECONNECT_NONE);

    cometd_advice_destroy(advice);
    json_node_free(msg);
    json_node_free(bad_connect);
}
Exemple #2
0
void
cometd_conn_destroy(cometd_conn* conn)
{
  if (conn->client_id != NULL)
    free(conn->client_id);

  cometd_advice_destroy(conn->advice);
  free(conn);
}
Exemple #3
0
END_TEST

START_TEST (test_cometd_msg_advice_retry)
{
  JsonNode* n = json_from_fixture("advice_reconnect_retry");

  cometd_advice* advice = cometd_msg_advice(n);
  ck_assert_int_eq(COMETD_RECONNECT_RETRY, advice->reconnect);
  ck_assert_int_eq(100, advice->interval);
  cometd_advice_destroy(advice);

  json_node_free(n);
}
Exemple #4
0
/**
 * Frees the existing advice if there is advice and sets the connection's
 * advice to "advice".  The pointer to which advice points is to be owned
 * by the connection and should not be free'd by the caller.
 */
void
cometd_conn_take_advice(cometd_conn* conn, cometd_advice* advice)
{
  cometd_advice_destroy(conn->advice);
  conn->advice = advice;
}