Scroll to navigation

WSLAY_EVENT_QUEUE_FRAGMENTED_MSG(3) wslay WSLAY_EVENT_QUEUE_FRAGMENTED_MSG(3)

NAME

wslay_event_queue_fragmented_msg - Queue a fragmented message for future transmission

SYNOPSIS

#include <wslay/wslay.h>



DESCRIPTION

wslay_event_queue_fragmented_msg() and wslay_event_queue_fragmented_msg_ex() queue a fragmented message specified in arg. The struct wslay_event_fragmented_msg is 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; };



The opcode member is the opcode of the message. The source member is an union and normally it contains a "source" to generate message data. The read_callback is a callback function called by wslay_event_send() to read message data from source. The implementation of wslay_event_fragmented_msg_callback must store at most len bytes of data to buf and return the number of stored bytes. If all data is read (i.e., EOF), set *eof to 1. If no data can be generated at the moment, return 0. If there is an error, return -1 and set error code WSLAY_ERR_CALLBACK_FAILURE using wslay_event_set_error().

This function supports non-control messages only. For control frames, use wslay_event_queue_msg() or wslay_event_queue_close().

This function just queues a message and does not send it. wslay_event_send() function call sends these queued messages.

wslay_event_queue_fragmented_msg_ex() additionally accepts rsv parameter, which is a reserved bits to send. To set reserved bits, use macro WSLAY_RSV1_BIT, WSLAY_RSV2_BIT, and WSLAY_RSV3_BIT. See wslay_event_config_set_allowed_rsv_bits() to see the allowed reserved bits to set.

RETURN VALUE

wslay_event_queue_fragmented_msg() and wslay_event_queue_fragmented_msg_ex() return 0 if it succeeds, or returns the following negative error codes:

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.
The given message is invalid; or bit is set in rsv which is not allowed (see wslay_event_config_set_allowed_rsv_bits()).
Out of memory.

SEE ALSO

wslay_event_queue_msg(), wslay_event_queue_msg_ex(), wslay_event_queue_close()

AUTHOR

Tatsuhiro Tsujikawa

COPYRIGHT

2021, 2015, Tatsuhiro Tsujikawa

July 9, 2021 1.1.1