MCO_RET mco_lews_send_websocket_data_frame(
lews_connection_context_h ctx,
const char *data,
mco_size_t data_size,
mco_bool is_text
);
ctx
data
data_size
is_text
1 for text, 0 for binary data.This function sends a WebSocket data frame over an established connection.
The data is automatically wrapped in a WebSocket frame with the appropriate opcode (
TEXTorBINARY) based on theis_textflag.The connection must already be upgraded to WebSocket via a successful handshake before calling this function.
... sz = snprintf(str_buf, sizeof(str_buf), "#%d Hello World", i); if (MCO_S_OK != mco_lews_send_websocket_data_frame(p_ctx, str_buf, sz, 1)) { printf("mco_lews_send_websocket_data_frame error %d\n", ret); return; } ...
MCO_S_OK
MCO_E_NW_SENDERR
MCO_E_LEWS_NO_ENOUGH_MEMORY