int main(void) { /* Set up the libevent library. */ event_init(); /* Set up the PubNub library, with a single shared context, * using the libevent backend for event handling. */ struct pubnub *p = pubnub_init("demo", "demo", &pubnub_libevent_callbacks, pubnub_libevent_init()); /* Set the terminal interaction handlers. */ terminal_interactive(); atexit(terminal_cooked); struct event ev; event_set(&ev, 0 /*stdin*/, EV_READ | EV_PERSIST, read_stdin, p); event_add(&ev, NULL); /* Start the event loop. */ event_dispatch(); /* We should never reach here. */ pubnub_done(p); return EXIT_SUCCESS; }
int main(void) { /* Set up the libevent library. */ event_init(); /* Set up the PubNub library, with a single shared context, * using the libevent backend for event handling. */ struct pubnub *p = pubnub_init("demo", "demo", &pubnub_libevent_callbacks, pubnub_libevent_init()); /* Set the clock update timer. */ evtimer_set(&clock_update_timer, clock_update, NULL); clock_update(-1, EV_TIMEOUT, NULL); /* First step in the PubNub call sequence is publishing a message. */ publish(p); /* Here, we could start any other asynchronous operations as needed, * launch a GUI or whatever. */ /* Start the event loop. */ event_dispatch(); /* We should never reach here. */ pubnub_done(p); return EXIT_SUCCESS; }