- websocket:send(opcode, message)
- websocket:sendText(message)
- websocket:sendBinary(message)
- websocket:sendPing(message)
- websocket:sendClose([status, reason])
SYNOPSIS
DESCRIPTION
These are a group of functions to send a message to the peer.
The most basic is websocket:send(). The opcode and the message contents can be freely specified.
The functions websocket:sendText(), websocket:sendBinary() and websocket:sendPing() are simple shortcuts of the previous function. The opcode is preset to 1, 2 and 9, respectively, as per RFC6455.
To inform the peer that the websocket communication is to end, call websocket:sendClose(). The optional parameters allow setting a specific close status code and reason string. By default, the status code is 1000 (normal close) and the reason is set to the string "Connection closed". After sending a close, no other messages are allowed to be sent to this socket.
RETURN VALUE
All send functions return a boolean true/false to indicate success.
In case of an error, the error can be retrieved using websocket:lastError().