Prepare for sending a new message. OpCode is one of text
,
binary
, close
, ping
or pong
. RSV is reserved for
extensions. After this call, the application usually writes data
to WSStream and uses ws_send/1 to complete the message.
Depending on OpCode, the stream is switched to binary (for
OpCode is binary
) or text using utf8
encoding (all other
OpCode values). For example, to a JSON message can be send
using:
ws_send_json(WSStream, JSON) :-
ws_start_message(WSStream, text),
json_write(WSStream, JSON),
ws_send(WSStream).