pubnub_t* pubnub_init(pubnub_t *p, const char *publish_key, const char *subscribe_key) { PUBNUB_ASSERT(pb_valid_ctx_ptr(p)); pubnub_mutex_init(p->monitor); pubnub_mutex_lock(p->monitor); pbcc_init(&p->core, publish_key, subscribe_key); if (PUBNUB_TIMERS_API) { p->transaction_timeout_ms = PUBNUB_DEFAULT_TRANSACTION_TIMER; #if defined(PUBNUB_DEFAULT_CONNECTION_TIMER) p->connection_timeout_s = PUBNUB_DEFAULT_CONNECTION_TIMER; #endif #if defined(PUBNUB_CALLBACK_API) p->previous = p->next = NULL; #endif } #if defined(PUBNUB_CALLBACK_API) p->cb = NULL; p->user_data = NULL; #endif if (PUBNUB_ORIGIN_SETTABLE) { p->origin = PUBNUB_ORIGIN; } p->state = PBS_IDLE; p->trans = PBTT_NONE; pbpal_init(p); pubnub_mutex_unlock(p->monitor); return p; }
pubnub_t* pubnub_init(pubnub_t *p, const char *publish_key, const char *subscribe_key) { PUBNUB_ASSERT(pb_valid_ctx_ptr(p)); pbcc_init(&p->core, publish_key, subscribe_key); if (PUBNUB_TIMERS_API) { p->transaction_timeout_ms = PUBNUB_DEFAULT_TRANSACTION_TIMER; } if (PUBNUB_ORIGIN_SETTABLE) { p->origin = PUBNUB_ORIGIN; } p->state = PBS_IDLE; p->trans = PBTT_NONE; pbpal_init(p); return p; }