WSLAY_EVENT_QU...AGMENTED_MSG_EX(3)
β¨ WSLAY_EVENT_QUEUE_FRAGMENTED_MSG_EX β¨
okay bestie, buckle up π this one's from the wslay manual, section 3, and it's giving "I queue things and then I simply do not send them, that's the bit." Let's get into it π«Ά
πΈ NAME πΈ
wslay_event_queue_fragmented_msg_ex β queue a fragmented message for future transmission π
π SYNOPSIS π
#include <wslay/wslay.h>
int wslay_event_queue_fragmented_msg(wslay_event_context_ptr ctx, const
struct wslay_event_fragmented_msg *arg)
int wslay_event_queue_fragmented_msg_ex(wslay_event_context_ptr ctx,
const struct wslay_event_fragmented_msg *arg, uint8_t rsv)
π¦ DESCRIPTION π¦
So like, wslay_event_queue_fragmented_msg() and wslay_event_queue_fragmented_msg_ex() both queue up a fragmented message, and the deets live in arg. The struct wslay_event_fragmented_msg is literally defined as:
union wslay_event_msg_source {
int fd;
void *data;
};
struct wslay_event_fragmented_msg {
uint8_t opcode;
union wslay_event_msg_source source;
wslay_event_fragmented_msg_callback read_callback;
};
and the callback type itself:
typedef ssize_t
(*wslay_event_fragmented_msg_callback)(wslay_event_context_ptr ctx,
uint8_t *buf, size_t len, const union wslay_event_msg_source *source,
int *eof, void *user_data)
Let's break the struct down, no gatekeeping π
- the
opcodemember is the opcode of the message, periodt - the
sourcemember is a union, and normally it's holding a "source" so you can generate message data read_callbackis a callback function thatwslay_event_send()calls to read message data fromsource
Now the callback rules, and bestie these are not optional π β your implementation of wslay_event_fragmented_msg_callback:
- must store at most
lenbytes of data intobuf, and return how many bytes it actually stored - if all the data is read (i.e. EOF), set
*eofto1 - if no data can be generated at the moment, return
0 - if there's an error, return
-1and set the error codeWSLAY_ERR_CALLBACK_FAILUREusingwslay_event_set_error()
β οΈ heads up: this function supports non-control messages only. For control frames, go usewslay_event_queue_msg()orwslay_event_queue_close()instead, ok?
Also important, and this trips people up: this function just queues a message and does not send it. The wslay_event_send() function call is what actually sends these queued messages. Queuing is the vibe, sending is the follow-through π
And now the _ex version, the glow-up β¨ β wslay_event_queue_fragmented_msg_ex() additionally accepts the rsv parameter, which is the reserved bits to send. To set reserved bits, use the macros WSLAY_RSV1_BIT, WSLAY_RSV2_BIT, and WSLAY_RSV3_BIT. And to see which reserved bits you're actually allowed to set, check wslay_event_config_set_allowed_rsv_bits() π
π RETURN VALUE π
wslay_event_queue_fragmented_msg() and wslay_event_queue_fragmented_msg_ex() return 0 if it succeeds π or they return one of these negative error codes:
WSLAY_ERR_NO_MORE_MSGβ Could not queue given message. The one of possible reason is that close control frame has been queued/sent and no further queueing message is not allowed.WSLAY_ERR_INVALID_ARGUMENTβ The given message is invalid; or bit is set inrsvwhich is not allowed (seewslay_event_config_set_allowed_rsv_bits()).WSLAY_ERR_NOMEMβ Out of memory.
π SEE ALSO π
wslay_event_queue_msg()wslay_event_queue_msg_ex()wslay_event_queue_close()
π AUTHOR π
Tatsuhiro Tsujikawa β the icon, the moment, the main character π«Ά
π COPYRIGHT π
2024, 2015, Tatsuhiro Tsujikawa
and that's the whole page, bestie!! πβ¨ this one's package version @PACKAGE_VERSION@, dated Apr 22, and it lives in the wslay manual section 3. go queue something cute π
π¦
π¦ 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