object
http_websocket
High-level WebSocket predicates for opening and closing connections, exchanging messages, and running common client and server session loops.
logtalk_load(http_websocket(loader))static, context_switching_callsPublic predicates
open/2
Opens a client WebSocket connection to the given ws:// or wss:// URL and returns an opaque handle managed by this object.
staticopen(URL,WebSocket)open(+atom,-compound) - one_or_errorURL is a variable:instantiation_errorURL is not a supported absolute WebSocket URL:domain_error(http_client_websocket_url,URL)URL uses an unsupported WebSocket scheme:domain_error(http_client_websocket_scheme,Scheme)open/3
Opens a client WebSocket connection to the given URL, returning an opaque handle. Client handshake options are forwarded to http_client::open_websocket/4. The direct API also accepts auto_pong(on|off) and max_payload_length(Bytes|none) options.
staticopen(URL,WebSocket,Options)open(+atom,-compound,+list) - one_or_errorURL is a variable:instantiation_errorURL is not a supported absolute WebSocket URL:domain_error(http_client_websocket_url,URL)URL uses an unsupported WebSocket scheme:domain_error(http_client_websocket_scheme,Scheme)Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Options contains an invalid direct WebSocket option:domain_error(http_websocket_option,Option)Options contains an invalid WebSocket client option:domain_error(http_client_websocket_option,Option)domain_error(http_client_websocket_response,Response)accept/3
Accepts one incoming WebSocket connection on the given listener using the default opening-handshake policy and returns an opaque server-side handle together with the accepted client information.
staticaccept(Listener,WebSocket,ClientInfo)accept(+compound,-compound,-compound) - one_or_errorexistence_error(http_socket_transport_websocket_request,Request)domain_error(http_socket_transport_websocket_response,Response)accept/4
Accepts one incoming WebSocket connection on the given listener and returns an opaque server-side handle. Server opening-handshake options are forwarded to http_server_core::accept_websocket/3. The direct API also accepts auto_pong(on|off) and max_payload_length(Bytes|none) options.
staticaccept(Listener,WebSocket,ClientInfo,Options)accept(+compound,-compound,-compound,+list) - one_or_errorOptions is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Options contains an invalid direct WebSocket option:domain_error(http_websocket_option,Option)existence_error(http_socket_transport_websocket_request,Request)domain_error(http_socket_transport_websocket_response,Response)send/2
Writes one outbound WebSocket message using the opaque handle. Accepts normalized message(Type, Payload) terms and the convenience wrappers text(Text), binary(Bytes), ping(Bytes), pong(Bytes), close(Payload), json(JSON), and term(Term).
staticsend(WebSocket,Message)send(+compound,+term) - one_or_errorWebSocket is a variable:instantiation_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)WebSocket refers to a closed opaque WebSocket handle:existence_error(http_websocket_handle,WebSocket)Message is not a valid outbound WebSocket message:domain_error(http_websocket_message,Message)send/3
Writes one outbound WebSocket message using the opaque handle and the given write options, forwarding those options to the underlying session write_message/5 predicate.
staticsend(WebSocket,Message,Options)send(+compound,+term,+list) - one_or_errorWebSocket is a variable:instantiation_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)Message is not a valid outbound WebSocket message:domain_error(http_websocket_message,Message)Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Options contains an invalid write option:domain_error(http_websocket_session_write_option,Option)receive/2
Reads the next normalized WebSocket message using the opaque handle. Returns end_of_file when the peer closes the transport before another message is available.
staticreceive(WebSocket,Message)receive(+compound,-term) - one_or_errorWebSocket is a variable:instantiation_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)WebSocket refers to a closed opaque WebSocket handle:existence_error(http_websocket_handle,WebSocket)domain_error(http_websocket_session_sequence,Frame)receive/3
Reads the next normalized WebSocket message using the opaque handle and the given read options. The direct API accepts per-call auto_pong(on|off) and max_payload_length(Bytes|none) overrides.
staticreceive(WebSocket,Message,Options)receive(+compound,-term,+list) - one_or_errorWebSocket is a variable:instantiation_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Options contains an invalid direct WebSocket option:domain_error(http_websocket_option,Option)domain_error(http_websocket_session_sequence,Frame)close/1
Best-effort graceful close of the WebSocket handle using the normal close payload empty.
staticclose(WebSocket)close(+compound) - one_or_errorWebSocket is a variable:instantiation_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)WebSocket refers to a closed opaque WebSocket handle:existence_error(http_websocket_handle,WebSocket)close/2
Best-effort graceful close of the WebSocket handle using the given close payload, which must be valid for a normalized message(close, Payload) term.
staticclose(WebSocket,Payload)close(+compound,+term) - one_or_errorWebSocket is a variable:instantiation_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)Payload is not a valid close payload:domain_error(http_websocket_close_payload,Payload)property/2
Enumerates properties of an open opaque WebSocket handle. Supported properties are role(Role), transport(Transport), response(Response), connection(Connection), state(State), client_info(ClientInfo), and subprotocol(Protocol).
staticproperty(WebSocket,Property)property(+compound,+compound) - zero_or_oneproperty(+compound,-compound) - zero_or_moresend_text/2
Convenience wrapper for sending one text message.
staticsend_text(WebSocket,Text)send_text(+compound,+atom) - one_or_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)Text is not a valid text payload:domain_error(http_websocket_message_text,Text)receive_text/2
Reads the next message and returns its text payload when the message type is text. Returns end_of_file unchanged.
staticreceive_text(WebSocket,Text)receive_text(+compound,-term) - one_or_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)domain_error(http_websocket_text_message,Message)send_binary/2
Convenience wrapper for sending one binary message.
staticsend_binary(WebSocket,Bytes)send_binary(+compound,+list(byte)) - one_or_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)Bytes is not a valid binary payload:domain_error(http_websocket_message,Message)receive_binary/2
Reads the next message and returns its binary payload when the message type is binary. Returns end_of_file unchanged.
staticreceive_binary(WebSocket,Bytes)receive_binary(+compound,-term) - one_or_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)domain_error(http_websocket_binary_message,Message)send_json/2
Serializes a JSON term as UTF-8 text and sends it as one text message. Uses curly terms for parsed JSON objects, dashes for parsed JSON pairs, and atoms for parsed JSON strings.
staticsend_json(WebSocket,JSON)send_json(+compound,+nonvar) - one_or_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)JSON cannot be serialized as a text WebSocket message:domain_error(json_sink,JSON)receive_json/2
Reads the next text message and decodes its payload as JSON. Returns end_of_file unchanged. Uses curly terms for parsed JSON objects, dashes for parsed JSON pairs, and atoms for parsed JSON strings.
staticreceive_json(WebSocket,JSON)receive_json(+compound,-term) - one_or_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)domain_error(http_websocket_json_text,Text)send_term/2
Serializes a Prolog term using canonical write options and sends it as one text message.
staticsend_term(WebSocket,Term)send_term(+compound,+term) - one_or_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)Term cannot be serialized as a text WebSocket message:domain_error(http_websocket_term_text,Text)receive_term/2
Reads the next text message and parses its payload as one Prolog term. Returns end_of_file unchanged.
staticreceive_term(WebSocket,Term)receive_term(+compound,-term) - one_or_errorWebSocket is not an open opaque WebSocket handle:domain_error(http_websocket_handle,WebSocket)domain_error(http_websocket_term_text,Text)open_session/4
Convenience wrapper over http_websocket_client_service::open/4 that keeps the user in the high-level http_websocket surface for callback-driven client sessions.
staticopen_session(URL,Handler,Response,State)open_session(+atom,+object_identifier,-compound,-compound) - one_or_errorURL is not a supported absolute WebSocket URL:domain_error(http_client_websocket_url,URL)Handler is not a valid WebSocket service handler:domain_error(http_websocket_service_handler,Handler)open_session/5
Convenience wrapper over http_websocket_client_service::open/5.
staticopen_session(URL,Handler,Response,State,Options)open_session(+atom,+object_identifier,-compound,-compound,+list) - one_or_errorURL is not a supported absolute WebSocket URL:domain_error(http_client_websocket_url,URL)Handler is not a valid WebSocket service handler:domain_error(http_websocket_service_handler,Handler)Options contains an invalid WebSocket client service option:domain_error(http_websocket_client_service_option,Option)Options contains an invalid WebSocket service loop option:domain_error(http_websocket_service_option,Option)serve_once/5
Convenience wrapper that accepts one incoming WebSocket connection on the given listener, performs the opening handshake using the default server policy, and runs one callback-driven server session.
staticserve_once(Listener,Handler,Response,State,ClientInfo)serve_once(+compound,+object_identifier,-compound,-compound,-compound) - one_or_errorHandler is not a valid WebSocket service handler:domain_error(http_websocket_service_handler,Handler)existence_error(http_socket_transport_websocket_request,Request)domain_error(http_socket_transport_websocket_response,Response)serve_once/6
Convenience wrapper that accepts one incoming WebSocket connection on the given listener and runs one callback-driven server session using the given combined handshake and session options.
staticserve_once(Listener,Handler,Response,State,ClientInfo,Options)serve_once(+compound,+object_identifier,-compound,-compound,-compound,+list) - one_or_errorHandler is not a valid WebSocket service handler:domain_error(http_websocket_service_handler,Handler)Options contains an invalid WebSocket service loop option:domain_error(http_websocket_service_option,Option)existence_error(http_socket_transport_websocket_request,Request)domain_error(http_socket_transport_websocket_response,Response)Protected predicates
(no local declarations; see entity ancestors if any)
Private predicates
handle_seed_/1
Last allocated opaque WebSocket handle identifier.
dynamichandle_seed_(HandleId)handle_seed_(?positive_integer) - zero_or_onehandle_state_/9
Stored opaque WebSocket handle state.
dynamichandle_state_(HandleId,Role,Transport,Connection,Response,ClientInfo,State,AutoPong,MaxPayloadLength)handle_state_(?positive_integer,?atom,?object_identifier,?compound,?compound,?term,?compound,?atom,?term) - zero_or_moreOperators
(none)