ws_easy_run - check pending WebSockets transfers#
-
_Bool ws_easy_run(struct websockets *ws, uint64_t wait_ms, uint64_t *tstamp)#
Reads/Write available data from WebSockets.
Note
This is an easy, yet highly abstracted way of performing transfers. If a higher control is necessary, users are better of using functions of
curl_multi_xxx()
family.- Parameters:
ws – the WebSockets handle created with ws_init()
wait_ms – limit amount in milliseconds to wait for until activity
tstamp – get current timestamp for this iteration
- Returns:
true
if connection is still alive,false
otherwise
Example#
CURLM *mhandle = curl_multi_init();
struct websockets *ws = ws_init(&cbs, mhandle, NULL);
ws_set_url(ws, "wss://example.com", NULL);
/* run the event-loop */
ws_start(ws);
uint64_t tstamp;
bool is_running;
do {
is_running = ws_easy_run(ws, 5, &tstamp);
} while (is_running);
ws_end(ws);
ws_cleanup(ws);
curl_multi_cleanup(mhandle);