ws_set_url - set WebSockets URL#
-
void ws_set_url(struct websockets *ws, const char base_url[], const char ws_protocols[])#
Set the URL for the WebSockets handle to connect.
- Parameters:
ws – the WebSockets handle created with ws_init()
base_url – the URL to connect, such as ws://echo.websockets.org
ws_protocols – NULL or something like “chat”, “superchat”,…
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);