Orca
A bot framework that is easy to reason about, easy to debug, and easy to use.
|
Go to the documentation of this file.
41 WS_CLOSE_REASON_NORMAL = 1000,
42 WS_CLOSE_REASON_GOING_AWAY = 1001,
43 WS_CLOSE_REASON_PROTOCOL_ERROR = 1002,
44 WS_CLOSE_REASON_UNEXPECTED_DATA = 1003,
45 WS_CLOSE_REASON_NO_REASON = 1005,
46 WS_CLOSE_REASON_ABRUPTLY = 1006,
47 WS_CLOSE_REASON_INCONSISTENT_DATA = 1007,
48 WS_CLOSE_REASON_POLICY_VIOLATION = 1008,
49 WS_CLOSE_REASON_TOO_BIG = 1009,
50 WS_CLOSE_REASON_MISSING_EXTENSION = 1010,
51 WS_CLOSE_REASON_SERVER_ERROR = 1011,
52 WS_CLOSE_REASON_IANA_REGISTRY_START = 3000,
53 WS_CLOSE_REASON_IANA_REGISTRY_END = 3999,
54 WS_CLOSE_REASON_PRIVATE_START = 4000,
55 WS_CLOSE_REASON_PRIVATE_END = 4999
124 void ws_set_url(
struct websockets *ws,
const char base_url[],
const char ws_protocols[]);
137 bool ws_send_text(
struct websockets *ws,
char text[],
size_t len);
145 void ws_start(
struct websockets *ws);
157 void ws_perform(
struct websockets *ws, _Bool *is_running, uint64_t wait_ms);
201 void ws_exit_event_loop(
struct websockets *ws);
203 bool ws_same_thread(
struct websockets *ws);
207 #endif // __cplusplus
209 #endif // WEBSOCKETS_H
@ WS_DISCONNECTED
client disconnected from ws
Definition: websockets.h:26
uint64_t ws_timestamp(struct websockets *ws)
The WebSockets handle concept of "now".
struct websockets * ws_init(struct ws_callbacks *cbs, struct logconf *config)
Create a new (CURL-based) WebSockets handle.
@ WS_CONNECTING
client in the process of connecting from ws
Definition: websockets.h:29
void ws_start(struct websockets *ws)
Signals connecting state before entering the WebSockets event loop.
void ws_set_url(struct websockets *ws, const char base_url[], const char ws_protocols[])
Set the URL for the WebSockets handle to connect.
void(* on_text)(void *data, const char *text, size_t len)
Reports UTF-8 text messages.
Definition: websockets.h:72
bool ws_send_text(struct websockets *ws, char text[], size_t len)
Send a text message of given size.
void(* on_connect)(void *data, const char *protocols)
Called upon connection.
Definition: websockets.h:64
enum ws_status ws_get_status(struct websockets *ws)
Returns the WebSockets handle connection status.
void * data
user arbitrary data to be passed around callbacks
Definition: websockets.h:98
bool ws_is_functional(struct websockets *ws)
Check if WebSockets connection is active.
@ WS_DISCONNECTING
client in the process of disconnecting to ws
Definition: websockets.h:28
ws_status
The WebSockets client status.
Definition: websockets.h:25
ws_close_reason
Definition: websockets.h:40
void ws_perform(struct websockets *ws, _Bool *is_running, uint64_t wait_ms)
Reads/Write available data from WebSockets.
void(* on_ping)(void *data, const char *reason, size_t len)
reports PING.
Definition: websockets.h:83
void ws_cleanup(struct websockets *ws)
Free a WebSockets handle created with ws_init()
bool ws_is_alive(struct websockets *ws)
Check if a WebSockets connection is alive.
void(* on_pong)(void *data, const char *reason, size_t len)
reports PONG.
Definition: websockets.h:87
void(* on_close)(void *data, enum ws_close_reason wscode, const char *reason, size_t len)
reports server closed the connection with the given reason.
Definition: websockets.h:94
Definition: websockets.h:58
void(* on_binary)(void *data, const void *mem, size_t len)
reports binary data.
Definition: websockets.h:76
char * ws_close_opcode_print(enum ws_close_reason opcode)
Returns a enum ws_close_reason opcode in a string format.
@ WS_CONNECTED
client connected to ws
Definition: websockets.h:27