HTTPc_WebSockSend
Send a WebSocket message.
Files
http-c.h/http-c.c
Prototype
CPU_BOOLEAN HTTPc_WebSockSend (HTTPc_CONN_OBJ *p_conn_obj, HTTPc_WEBSOCK_MSG_OBJ *p_msg_obj, HTTPc_WEBSOCK_MSG_TYPE msg_type, CPU_CHAR *p_data, CPU_INT32U payload_len, HTTPc_FLAGS flags, HTTPc_ERR *p_err)
Arguments
p_conn_obj
Pointer to the HTTPc Connection Object for which to open the socket.
p_msg_obj
Pointer to a valid HTTPc WebSocket Message Object .
msg_type
Type of message to send.
p_data
Pointer to the payload to send.
data_len
Length of the payload to send.
flags
Configuration flags:
HTTPc_FLAG_WEBSOCK_NO_BLOCK
p_err
Pointer to variable that will receive the return error code from this function:
HTTPc_ERR_NONE
HTTPc_ERR_INIT_NOT_COMPLETED
HTTPc_ERR_NULL_PTR
HTTPc_ERR_FEATURE_DIS
HTTPc_ERR_WEBSOCK_INVALID_CONN
HTTPc_ERR_WEBSOCK_INVALID_TX_PARAM
HTTPc_ERR_WEBSOCK_MSG_IS_USED
HTTPc_ERR_MSG_Q_FULL
HTTPc_ERR_MSG_Q_SIGNAL_FAULT
HTTPc_ERR_CONN_SIGNAL_CREATE
HTTPc_ERR_CONN_SIGNAL_TIMEOUT
HTTPc_ERR_CONN_SIGNAL_FAULT
HTTPc_ERR_CONN_SIGNAL_DEL
Returned Values
DEF_OK,
if the operation is successful.
DEF_FAIL,
if the operation has failed.
Required Configuration
None.
Notes / Warnings
The connection object p_conn MUST has been previously upgraded to WebSocket to use this function. Refer to the HTTPc_WebSockUpgrade() function.
The available Message Types are :
HTTPc_WEBSOCK_MSG_TYPE_TXT_FRAME
HTTPc_WEBSOCK_MSG_TYPE_BIN_FRAME
HTTPc_WEBSOCK_MSG_TYPE_CLOSE
HTTPc_WEBSOCK_MSG_TYPE_PING
HTTPc_WEBSOCK_MSG_TYPE_PONG
Payload Content:
The "Payload data" (argument p_data) is defined as "Extension data" concatenated with "Application data".
Extension data length is 0 Bytes unless an extension has been negotiated during the handshake.
"Extension data" content and length are defines by the extension negotiated. If negotiated, the "Extension data" must be handled by the Application.
Data message Restrictions:
Even if the RFC6455 allow to sent message payload up to 2^64 bytes, Only 2^32 bytes is allowed in the current implementation.
Control message Restrictions:
According to the RFC 6455 section 5.5: "All control frames MUST have a payload length of 125 bytes or less and MUST NOT be fragmented."
Close frame have a specific payload format. Refer to the HTTPc_WebSockFmtCloseMsg() function for more information.
Client-to-Server Masking
According to the RFC 6455 section 5.2: "All frames sent from the client to the server are masked by a 32-bit value that is contained within the frame."
The Application DO NOT need to mask the payload since it's handled by the WebSocket module.