cometd* cometd_new(void) { // we need to initialize glib :-/ cometd_types_init(); cometd* h = malloc(sizeof(cometd)); // config cometd_config* config = malloc(sizeof(cometd_config)); config->url = ""; config->backoff_increment = DEFAULT_BACKOFF_INCREMENT; config->max_backoff = DEFAULT_MAX_BACKOFF; config->max_network_delay = DEFAULT_MAX_NETWORK_DELAY; config->request_timeout = DEFAULT_REQUEST_TIMEOUT; config->append_message_type_to_url = DEFAULT_APPEND_MESSAGE_TYPE; config->transports = NULL; config->webSockState = true; cometd_register_transport(config, &COMETD_TRANSPORT_LONG_POLLING); h->exts = NULL; h->conn = cometd_conn_new(); // connection h->loop = cometd_loop_new(gthread, h); // run loop h->inbox = cometd_inbox_new(h->loop); // inbox h->subscriptions = cometd_listener_new(); // events h->last_error = cometd_error_new(); // set internal handlers cometd_impl_set_sys_s(h); h->config = config; return h; }
static void setup(void) { log_clear(); listeners = cometd_listener_new(); }