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

#include <curl-websocket.h>

Data Fields

void(* on_connect )(void *data, CURL *easy, const char *websocket_protocols)
 
void(* on_text )(void *data, CURL *easy, const char *text, size_t len)
 
void(* on_binary )(void *data, CURL *easy, const void *mem, size_t len)
 
void(* on_ping )(void *data, CURL *easy, const char *reason, size_t len)
 
void(* on_pong )(void *data, CURL *easy, const char *reason, size_t len)
 
void(* on_close )(void *data, CURL *easy, enum cws_close_reason reason, const char *reason_text, size_t reason_text_len)
 
const void * data
 

Field Documentation

◆ on_connect

void(* cws_callbacks::on_connect) (void *data, CURL *easy, const char *websocket_protocols)

called upon connection, websocket_protocols contains what server reported as 'Sec-WebSocket-Protocol:'.

Note
It is not validated if matches the proposed protocols.

◆ on_text

void(* cws_callbacks::on_text) (void *data, CURL *easy, 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 CWS_CLOSE_REASON_INCONSISTENT_DATA.

◆ on_binary

void(* cws_callbacks::on_binary) (void *data, CURL *easy, const void *mem, size_t len)

reports binary data.

◆ on_ping

void(* cws_callbacks::on_ping) (void *data, CURL *easy, const char *reason, size_t len)

reports PING.

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

◆ on_pong

void(* cws_callbacks::on_pong) (void *data, CURL *easy, const char *reason, size_t len)

reports PONG.

◆ on_close

void(* cws_callbacks::on_close) (void *data, CURL *easy, enum cws_close_reason reason, const char *reason_text, size_t reason_text_len)

reports server closed the connection with the given reason.

Clients should not transmit any more data after the server is closed, just call cws_free().

◆ data

const void* cws_callbacks::data

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