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 opcode member is the opcode of the message
  • the msg member is the pointer to the message data
  • the msg_length member 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 (see wslay_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 ✨


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