Availability:
:- use_module(library(http/websocket)).
[det]ws_open(+Stream,
-WSStream, +Options)- mode(+Mode)
- One of
serverorclient. Ifclient, messages are sent as masked. - buffer_size(+Count)
- Send partial messages for each Count bytes or when flushing the output. The default is to buffer the entire message before it is sent.
- close_parent(+Boolean)
- If
true(default), closing WSStream also closes Stream. - max_message_size(+Bytes)
- Raise an I/O error when reading a message whose (total) payload is
larger than Bytes. Bytes is a positive integer or
infinite. The default is 16Mb (16,777,216 bytes). - subprotocol(+Protocol)
- Set the subprotocol property of WsStream. This value can be retrieved
using ws_property/2. Protocol
is an atom. See also the
subprotocolsoption of http_open_websocket/3 and http_upgrade_to_websocket/3.
A typical sequence to turn a pair of streams into a WebSocket is here:
...,
Options = [mode(server), subprotocol(chat)],
ws_open(Input, WsInput, Options),
ws_open(Output, WsOutput, Options),
stream_pair(WebSocket, WsInput, WsOutput).