2020-12-05 19:26:32 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#define WEBSOCKET_OP_CONTINUE 0
|
|
|
|
#define WEBSOCKET_OP_TEXT 1
|
|
|
|
#define WEBSOCKET_OP_BINARY 2
|
|
|
|
#define WEBSOCKET_OP_CLOSE 8
|
|
|
|
#define WEBSOCKET_OP_PING 9
|
|
|
|
#define WEBSOCKET_OP_PONG 10
|
|
|
|
|
|
|
|
#include "http.h"
|
|
|
|
|
|
|
|
struct mg_ws_message {
|
2021-09-15 14:43:48 +08:00
|
|
|
struct mg_str data; // Websocket message data
|
|
|
|
uint8_t flags; // Websocket message flags
|
2020-12-05 19:26:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mg_connection *mg_ws_connect(struct mg_mgr *, const char *url,
|
|
|
|
mg_event_handler_t fn, void *fn_data,
|
|
|
|
const char *fmt, ...);
|
2021-01-17 06:48:43 +08:00
|
|
|
void mg_ws_upgrade(struct mg_connection *, struct mg_http_message *,
|
|
|
|
const char *fmt, ...);
|
2020-12-05 19:26:32 +08:00
|
|
|
size_t mg_ws_send(struct mg_connection *, const char *buf, size_t len, int op);
|
2021-08-01 21:10:21 +08:00
|
|
|
size_t mg_ws_wrap(struct mg_connection *, size_t len, int op);
|