WSLAY_EVENT_QUEUE_CLOSE(3)
π WSLAY_EVENT_QUEUE_CLOSE π
okay bestie, welcome to wslay(3) β specifically the WSLAY_EVENT_QUEUE_CLOSE page. this one's short, sweet, and honestly kind of iconic. let's get into it β¨
πΈ NAME πΈ
wslay_event_queue_close β queue a close control frame π
π¦ SYNOPSIS π¦
#include <wslay/wslay.h>
int wslay_event_queue_close(wslay_event_context_ptr ctx, uint16_t
status_code, const uint8_t *reason, size_t reason_length)
like. look at her. four args, one return value, zero drama. π
β¨ DESCRIPTION β¨
so wslay_event_queue_close() queues a close control frame. that's the whole vibe fr fr.
real talk though β this function is provided just for convenience. it's giving "you could do this yourself, but why would you". because here's the thing: wslay_event_queue_msg() can queue a close control frame as well. so if you're already deep in that function's DMs, you're covered. wslay_event_queue_close() is just the easy button. π«Ά
now let's talk about the args, because they matter:
status_codeβ this is the status code of the close control frame. it's auint16_t, so it's a cute little number.reasonβ the close reason, encoded in UTF-8. yes, it has to be UTF-8, don't come at me with your latin-1 nonsense πreason_lengthβ the length ofreasonin bytes. not characters, bestie. bytes.
β οΈ and here's the one that will get you: reason_length must be less than 123 bytes. not less than or equal to. less than. 123 is the ceiling and you are not touching it. π
there's also a lil special case, and it's lowkey my fave:
if status_code is 0, then reason and reason_length are not used at all β they get ignored, no cap β and a close control frame with a zero-length payload will be queued instead. so you can just pass 0 and dip. π
and now the part everyone forgets:
this function just queues a message. it does not send it. π¨
nothing goes out on the wire from calling this. you have to call wslay_event_send() to actually send these queued messages. so don't queue your close frame and then sit there wondering why nothing happened, because that's on you, not on her. π
π₯ RETURN VALUE π₯
wslay_event_queue_close() returns 0 if it succeeds. slay. β
or it returns one of these negative error codes, and honestly, mood:
WSLAY_ERR_NO_MORE_MSGβ could not queue the given message. one of the possible reasons is that a close control frame has already been queued/sent, and no further queueing of a message is not allowed. so basically: you already closed the door, why are you trying to close it again πͺπWSLAY_ERR_INVALID_ARGUMENTβ the given message is invalid. something about your args is not passing the vibe check.WSLAY_ERR_NOMEMβ out of memory. π the classic.
π SEE ALSO π
go read these too, they're in the group chat:
wslay_event_queue_msg()wslay_event_queue_fragmented_msg()
π AUTHOR π
Tatsuhiro Tsujikawa β the icon, the legend, the moment. π
π COPYRIGHT π
2024, 2015, Tatsuhiro Tsujikawa
and that's the page, bestie!! π¦ this was @PACKAGE_VERSION@, dated Apr 22, 2024, living in section 3 of the wslay manual. queue responsibly, keep your reason_length under 123 bytes, and always remember to actually call wslay_event_send(). mwah πβ¨
π¦ 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