WSLAY_EVENT_SEND(3)

πŸ’– WSLAY_EVENT_SEND(3) πŸ’–

okay bestie, welcome to the wslay manual, section 3, and today's main character is wslay_event_send. yes she's a libc-adjacent queen, yes she's from the wslay fam, and yes we're gonna understand her completely. no cap. πŸ¦‹


✨ NAME ✨

wslay_event_send β€” send any pending messages πŸ’Œ


🌸 SYNOPSIS 🌸

#include <wslay/wslay.h>

int wslay_event_send(wslay_event_context_ptr ctx)

πŸŽ€ DESCRIPTION πŸŽ€

so like, wslay_event_send() sends all your queued messages over to the peer. that's her whole job and she eats every time. πŸ”₯

when she's actually sending a message, she uses the wslay_event_send_callback function to do it. and the way that one single call of wslay_event_send() keeps going and sends multiple messages until wslay_event_send_callback sets the error code WSLAY_ERR_WOULDBLOCK? it's giving efficient. it's giving iconic. πŸ’…

if ctx was initialized for WebSocket client use, then wslay_event_send() uses wslay_event_genmask_callback to get a fresh mask key. masking era, we love to see it ✨

and when a message that got queued using wslay_event_queue_fragmented_msg() is being sent, wslay_event_send() invokes wslay_event_fragmented_msg_callback for that message. teamwork makes the dream work fr fr 🫢

after a close control frame gets sent, this function calls wslay_event_set_write_enabled() with second argument 0 to disable any further transmission to the peer. bye bestie, connection's closing 😭

if there are any pending messages, wslay_event_want_write() returns 1. otherwise it returns 0. simple as that, lowkey.

and in case of a fatal error which leads to a negative return code, this function calls wslay_event_set_write_enabled() with second argument 0 to disable further transmission to the peer. like she's shutting the door, gently but firmly πŸ™ˆ


⭐ RETURN VALUE ⭐

wslay_event_send() returns 0 if it succeeds πŸŽ‰ β€” or one of these negative error codes if it does not:

  • WSLAY_ERR_CALLBACK_FAILURE β€” the user defined callback function is failed. not her fault, it's the callback's moment of weakness πŸ’€
  • WSLAY_ERR_NOMEM β€” out of memory. the RAM said no πŸ“
okay so IMPORTANT: when a negative error code is returned, the application must not make any further call of wslay_event_send() and must close the WebSocket connection. that's not a vibe suggestion, that's the rules. periodt. πŸ‘‘

🌈 SEE ALSO 🌈

  • wslay_event_queue_fragmented_msg()
  • wslay_event_set_write_enabled()
  • wslay_event_want_write()

πŸ‘‘ AUTHOR πŸ‘‘

Tatsuhiro Tsujikawa


2024, 2015, Tatsuhiro Tsujikawa


and that's the whole page bestie!! this manual page is from @PACKAGE_VERSION@, dated Apr 22, 2024, and it lives under the name WSLAY_EVENT_SEND(3). go forth and send those messages, you absolute legend πŸ§šπŸ’–

πŸ“¦ where this page comes from