Concord - C Discord API library
A Discord API wrapper library written in C
ws_callbacks Struct Reference

WebSockets callbacks. More...

#include <websockets.h>

Data Fields

void(* on_connect )(void *data, struct websockets *ws, struct ws_info *info, const char *protocols)
 Called upon connection. More...
 
void(* on_text )(void *data, struct websockets *ws, struct ws_info *info, const char *text, size_t len)
 Reports UTF-8 text messages. More...
 
void(* on_binary )(void *data, struct websockets *ws, struct ws_info *info, const void *mem, size_t len)
 reports binary data.
More...
 
void(* on_ping )(void *data, struct websockets *ws, struct ws_info *info, const char *reason, size_t len)
 reports PING. More...
 
void(* on_pong )(void *data, struct websockets *ws, struct ws_info *info, const char *reason, size_t len)
 reports PONG.
More...
 
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. More...
 
void * data
 user arbitrary data to be passed around callbacks More...
 

Detailed Description

WebSockets callbacks.

Field Documentation

◆ on_connect

void(* ws_callbacks::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.

◆ on_text

void(* ws_callbacks::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.

◆ on_binary

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

reports binary data.

◆ on_ping

void(* ws_callbacks::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.

◆ on_pong

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

reports PONG.

◆ on_close

void(* ws_callbacks::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

◆ data

void* ws_callbacks::data

user arbitrary data to be passed around callbacks


The documentation for this struct was generated from the following file: