summaryrefslogtreecommitdiff
path: root/src/curl/websocket.h
blob: 5eee73f5b36469e8ceda5584519dfc0d9fc28a62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma once

#include "../util/buffer.h"

#include "curl.h"

struct nn_websocket {
    struct nn_curl curl;
    struct nn_buffer frame;
    void (*callback)(void *, const struct curl_ws_frame *, u8 *, size_t);
    void *userdata;
};

bool nn_websocket_init(struct nn_websocket *ws);
void nn_websocket_set_url(struct nn_websocket *ws, str *url);
bool nn_websocket_connect(struct nn_websocket *ws, struct nn_event_loop *loop,
    void (*callback)(void *, const struct curl_ws_frame *, u8 *, size_t), void *userdata);
void nn_websocket_disconnect(struct nn_websocket *ws, u16 status);
bool nn_websocket_send_frame(struct nn_websocket *ws, u8 *data, size_t size);