示例#1
0
END_TEST

START_TEST (test_cometd_ext_fire_outgoing)
{
  cometd_ext* ext = cometd_ext_new();
  ext->outgoing = count_callback;
  cometd_ext_add(&exts, ext);
  cometd_ext_add(&exts, cometd_ext_new());

  cometd_ext_fire_outgoing(exts, NULL, NULL);

  ck_assert_int_eq(1, count);
}
示例#2
0
int	cometd_impl_send_msg_sync(const cometd* h, JsonNode* msg, cometd_transport* t)
{
  JsonNode *outgoing = cometd_msg_wrap_copy(msg);
  JsonNode *payload;
  int code = COMETD_SUCCESS;

  cometd_ext_fire_outgoing(h->exts, h, msg);

   
  if (t == NULL)
    payload = http_post_msg(h, outgoing);
  else
    payload = t->send(h, outgoing);

  json_node_free(outgoing);

  if (payload == NULL) {
    code = cometd_last_error(h)->code;
    goto failed_send;
  }

  code = cometd_impl_process_sync(h, payload);

  if (code != COMETD_SUCCESS) {
    code = cometd_error(h, code, "processing error");
    goto failed_processing;
  }

  if (!cometd_msg_is_successful(payload))
    code = ECOMETD_UNSUCCESSFUL;

failed_processing:
  json_node_free(payload);
failed_send:
  return code;
}