WSLAY_EVENT_QUEUE_MSG(3)
π WSLAY_EVENT_QUEUE_MSG(3) β the wslay manual, bestie edition
okay so you wanna queue up a WebSocket message for later transmission? say less, this page is literally your girl π
(it's part of the wslay manual, in case the (3) wasn't giving it away)
β¨ NAME β¨
wslay_event_queue_msg β Queue a message for future transmission π
πΈ SYNOPSIS πΈ
#include <wslay/wslay.h>
int wslay_event_queue_msg(wslay_event_context_ptr ctx, const struct
wslay_event_msg *arg)
int wslay_event_queue_msg_ex(wslay_event_context_ptr ctx, const struct
wslay_event_msg *arg, uint8_t rsv)
π¦ DESCRIPTION π¦
wslay_event_queue_msg() and wslay_event_queue_msg_ex() queue up the message you specify in arg. and like, what even is a wslay_event_msg? bestie, it's this:
struct wslay_event_msg {
uint8_t opcode;
const uint8_t *msg;
size_t msg_length;
};
let's break that down, no cap:
- the
opcodemember is the opcode of the message - the
msgmember is the pointer to the message data - the
msg_lengthmember is the length of the message data
so this function has range β it supports both control and non-control messages, and the message you hand it gets sent without fragmentation. no chopping, no slicing, just one clean serve π
not me about to fragment tho β if you do need fragmentation, use wslay_event_queue_fragmented_msg() instead, okay? different tool, different vibe.
also important: this function makes a copy of msg of length msg_length. it's not borrowing your buffer, it's taking its own lil photocopy and keeping it. so you can free your stuff after, iconic behavior π
and here's the thing β this function just queues a message. it does not send it. nothing is going out the door yet. the wslay_event_send() function call is what actually sends these queued messages. queue β send, they're two different main characters π«Ά
now, wslay_event_queue_msg_ex() is the extra one: it additionally accepts the rsv parameter, which is a reserved bits to send. to set reserved bits, use the macro WSLAY_RSV1_BIT, WSLAY_RSV2_BIT, and WSLAY_RSV3_BIT. and if you're wondering which ones you're even allowed to set? check wslay_event_config_set_allowed_rsv_bits() to see the allowed reserved bits. vibe check your permissions first, bestie π₯
π RETURN VALUE π
wslay_event_queue_msg() and wslay_event_queue_msg_ex() return 0 if it succeeds, or they hand you these negative error codes:
WSLAY_ERR_NO_MORE_MSGβ could not queue given message. one of the possible reasons is that a close control frame has been queued/sent and no further queueing message is not allowed. like, the party's over, no more entries πWSLAY_ERR_INVALID_ARGUMENTβ the given message is invalid; or RSV1 is set for control frame; or a bit is set in rsv which is not allowed (seewslay_event_config_set_allowed_rsv_bits()). yeah that one's on you πWSLAY_ERR_NOMEMβ out of memory. literally ran out of room, tragic π
π SEE ALSO π
wslay_event_queue_fragmented_msg()wslay_event_queue_fragmented_msg_ex()wslay_event_queue_close()
π AUTHOR π
Tatsuhiro Tsujikawa β¨
π COPYRIGHT π
2024, 2015, Tatsuhiro Tsujikawa
okay that's the whole page, we ate and left no crumbs π
version @PACKAGE_VERSION@ Β· dated Apr 22, 2024 Β· from the wslay manual β mwah, go queue something cute bestie π¦π
π¦ where this page comes from
- ubuntu noble: libwslay-doc 1.1.1-4build1 Β· MIT
- ubuntu questing: libwslay-doc 1.1.1-4build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms