Datatypes#

struct websockets#

Opaque handler for WebSockets.

struct ws_attr#

WebSockets handle initialization attributes.

Public Members

struct logconf *conf#

pre-initialized logging module

struct ws_info#

Stores info on the latest transfer performed via websockets.

Public Members

struct loginfo loginfo#

logging info

ORCAcode code#

how the transfer went

Todo:

implement

struct ws_callbacks#

WebSockets callbacks.

Public Members

void (*on_connect)(void *data, struct websockets *ws, struct ws_info *info, const char *protocols)#

Called upon connection.

Note

It is not validated if matches the proposed protocols.

void (*on_text)(void *data, struct websockets *ws, struct ws_info *info, const char *text, size_t len)#

Reports UTF-8 text messages.

Note

it’s guaranteed to be NULL (\0) terminated, but the UTF-8 is not validated. If it’s invalid, consider closing the connection with WS_CLOSE_REASON_INCONSISTENT_DATA.

void (*on_binary)(void *data, struct websockets *ws, struct ws_info *info, const void *mem, size_t len)#

reports binary data.

void (*on_ping)(void *data, struct websockets *ws, struct ws_info *info, const char *reason, size_t len)#

reports PING.

Note

if provided you should reply with ws_pong(). If not provided, pong is sent with the same message payload.

void (*on_pong)(void *data, struct websockets *ws, struct ws_info *info, const char *reason, size_t len)#

reports PONG.

void (*on_close)(void *data, struct websockets *ws, struct ws_info *info, enum ws_close_reason wscode, const char *reason, size_t len)#

reports server closed the connection with the given reason.

Clients should not transmit any more data after the server is closed

void *data#

user arbitrary data to be passed around callbacks

enum ws_status#

The WebSockets client status.

See also

ws_get_status()

Values:

enumerator WS_DISCONNECTED = 0#

client disconnected from ws

enumerator WS_CONNECTED#

client connected to ws

enumerator WS_DISCONNECTING#

client in the process of disconnecting to ws

enumerator WS_CONNECTING#

client in the process of connecting from ws

enum ws_close_reason#

WebSockets CLOSE opcodes.

Values:

enumerator WS_CLOSE_REASON_NORMAL = 1000#
enumerator WS_CLOSE_REASON_GOING_AWAY = 1001#
enumerator WS_CLOSE_REASON_PROTOCOL_ERROR = 1002#
enumerator WS_CLOSE_REASON_UNEXPECTED_DATA = 1003#
enumerator WS_CLOSE_REASON_NO_REASON = 1005#
enumerator WS_CLOSE_REASON_ABRUPTLY = 1006#
enumerator WS_CLOSE_REASON_INCONSISTENT_DATA = 1007#
enumerator WS_CLOSE_REASON_POLICY_VIOLATION = 1008#
enumerator WS_CLOSE_REASON_TOO_BIG = 1009#
enumerator WS_CLOSE_REASON_MISSING_EXTENSION = 1010#
enumerator WS_CLOSE_REASON_SERVER_ERROR = 1011#
enumerator WS_CLOSE_REASON_IANA_REGISTRY_START = 3000#
enumerator WS_CLOSE_REASON_IANA_REGISTRY_END = 3999#
enumerator WS_CLOSE_REASON_PRIVATE_START = 4000#
enumerator WS_CLOSE_REASON_PRIVATE_END = 4999#