object
http_websocket_messages(TextRepresentation)
TextRepresentation- Text representation to be used for text messages and close reasons. Possible values areatom(default),chars, andcodes.
Transport-neutral WebSocket message predicates built on top of the http_websocket frame layer.
logtalk_load(http_websocket_messages(loader))static, context_switching_calls
Fragmentation model: This layer reassembles fragmented text and binary messages only when all continuation frames arrive contiguously. Interleaved control frames during fragmented messages raise
http_websocket_message_sequence. Usehttp_websocket_sessionfor RFC 6455 live-stream processing that must surface interleaved control frames while reassembling data messages.
Public predicates
message/3
Constructs a validated normalized WebSocket message term from the message type atom and payload term.
staticmessage(Type,Payload,Message)message(+atom,+term,-compound) - one_or_errorType is not a supported WebSocket message type:domain_error(http_websocket_message_type,Type)Payload is not valid for the requested WebSocket message type:domain_error(http_websocket_message,Message)Payload is not a valid WebSocket close payload:domain_error(http_websocket_close_payload,Payload)Payload contains an invalid WebSocket close code:domain_error(http_websocket_close_code,Code)Payload is not valid text for the selected text representation:domain_error(http_websocket_message_text,Text)
Type
text: Payload is text in the selected text representation.Type
binary: Payload is a list of bytes.Type
pingorpong: Payload is a list of bytes.Type
close: Payload is one ofempty,status(Code), orstatus(Code, Reason).
is_message/1
True when the argument is a valid normalized WebSocket message term.
staticis_message(Message)is_message(@term) - zero_or_oneread_message/2
Reads one WebSocket message from a binary stream. Continuation frames are reassembled for text and binary messages when they arrive contiguously. Returns end_of_file when the stream is already exhausted.
staticread_message(Stream,Message)read_message(+stream_or_alias,-term) - one_or_errorStream is a variable:instantiation_errordomain_error(http_websocket_message_sequence,Frame)domain_error(http_websocket_frame,Frame)domain_error(http_websocket_message,Message)domain_error(http_websocket_message_text,Text)
Interleaved control frames: Control frames interleaved in the middle of a fragmented data message are not surfaced by this simplified layer and instead raise
http_websocket_message_sequence. Usehttp_websocket_sessionwhen interleaved control frames must be handled while a fragmented message is in progress.
write_message/2
Writes one validated WebSocket message as a single final frame to a binary stream and flushes the stream.
staticwrite_message(Stream,Message)write_message(+stream_or_alias,+compound) - one_or_errorStream is a variable:instantiation_errorMessage is not a valid normalized WebSocket message term:domain_error(http_websocket_message,Message)Message has an unsupported message type:domain_error(http_websocket_message_type,Type)Message has an invalid close payload:domain_error(http_websocket_close_payload,Payload)Message has invalid text for the selected text representation:domain_error(http_websocket_message_text,Text)type/2
Returns the type atom of a validated WebSocket message term.
statictype(Message,Type)type(+compound,-atom) - one_or_errorMessage is not a valid normalized WebSocket message term:domain_error(http_websocket_message,Message)Message has an unsupported message type:domain_error(http_websocket_message_type,Type)payload/2
Returns the payload term of a validated WebSocket message term.
staticpayload(Message,Payload)payload(+compound,-term) - one_or_errorMessage is not a valid normalized WebSocket message term:domain_error(http_websocket_message,Message)Message has an unsupported message type:domain_error(http_websocket_message_type,Type)Protected predicates
encode_message/4
Protected helper that normalizes a WebSocket message term and returns the normalized term together with the corresponding frame opcode and payload bytes.
staticencode_message(Message,NormalizedMessage,Opcode,PayloadBytes)encode_message(+compound,-compound,-atom,-list(byte)) - one_or_errorMessage is not a valid normalized WebSocket message term:domain_error(http_websocket_message,Message)Message has an unsupported message type:domain_error(http_websocket_message_type,Type)Message has an invalid close payload:domain_error(http_websocket_close_payload,Payload)Message has invalid text for the selected text representation:domain_error(http_websocket_message_text,Text)decode_message/3
Protected helper that decodes payload bytes for the given message type atom into a normalized WebSocket message term.
staticdecode_message(Type,PayloadBytes,Message)decode_message(+atom,+list(byte),-compound) - one_or_errorType is not a supported WebSocket message type:domain_error(http_websocket_message_type,Type)PayloadBytes is not a valid close payload:domain_error(http_websocket_close_payload,PayloadBytes)PayloadBytes contains an invalid close code:domain_error(http_websocket_close_code,Code)PayloadBytes does not decode to valid text for the selected text representation:domain_error(http_websocket_message_text,PayloadBytes)Private predicates
(no local declarations; see entity ancestors if any)
Operators
(none)