WSLAY_EVENT_QU...AGMENTED_MSG_EX(3)

πŸ“¦
version 1.1.1 Β· 4 versions
, in ubuntu noble, ubuntu questing

✨ 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 opcode member is the opcode of the message, periodt
  • the source member is a union, and normally it's holding a "source" so you can generate message data
  • read_callback is a callback function that wslay_event_send() calls to read message data from source

Now the callback rules, and bestie these are not optional πŸ™ˆ β€” your implementation of wslay_event_fragmented_msg_callback:

  • must store at most len bytes of data into buf, and return how many bytes it actually stored
  • if all the data is read (i.e. EOF), set *eof to 1
  • if no data can be generated at the moment, return 0
  • if there's an error, return -1 and set the error code WSLAY_ERR_CALLBACK_FAILURE using wslay_event_set_error()
⚠️ heads up: this function supports non-control messages only. For control frames, go use wslay_event_queue_msg() or wslay_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 in rsv which is not allowed (see wslay_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 🫢


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