object
http_websocket_service(HTTPTransport,Role,TextRepresentation)
HTTPTransport- The object implementinghttp_transport_protocol.Role- Peer role for masking policy. Possible values areclientandserver.TextRepresentation- Text representation to be used for text messages and close reasons. Possible values areatom(default),chars, andcodes.
Callback-driven WebSocket session loops over upgraded WebSocket connections provided by a selected http_transport_protocol implementation, including automatic close-handshake orchestration, optional auto-pong, keepalive, and idle-timeout policies.
logtalk_load(http_websocket_service(loader))static, context_switching_calls, threaded
Option precedence: When the same loop option is given multiple times, the first occurrence is used.
Timed policies: Keepalive and idle-timeout deadlines are tracked using wall-clock time, making the loop robust to scheduling jitter and slow reads.
Public predicates
run_session/3
Runs a higher-level session loop on an upgraded WebSocket connection produced by the selected transport parameterization until the close handshake completes or the peer closes the stream, then closes the upgraded connection automatically.
staticrun_session(Connection,Handler,State)run_session(+compound,+object_identifier,-compound) - one_or_errorConnection is a variable:instantiation_errorConnection is not a valid upgraded WebSocket connection handle:domain_error(http_socket_transport_connection,Connection)Handler is a variable:instantiation_errorHandler is not a valid WebSocket service handler:domain_error(http_websocket_service_handler,Handler)client nor server:domain_error(http_websocket_session_role,_Role_)domain_error(http_websocket_session_sequence,Frame)domain_error(http_websocket_session_masking,Frame)domain_error(http_websocket_session_extensions,Frame)domain_error(http_websocket_frame,Frame)domain_error(http_websocket_message_text,Payload)Handler returns a variable reply list:instantiation_errorHandler returns a non-list reply list:type_error(list,Replies)Handler returns an invalid reply:domain_error(http_websocket_service_handler_reply,Reply)
Handler protocol: The handler object must conform to the
http_websocket_service_handler_protocolprotocol and return a list of normalized reply messages for each received message.Connection ownership: This predicate takes ownership of the upgraded connection and closes it before succeeding or rethrowing any exception.
run_session/4
Runs a higher-level session loop on an upgraded WebSocket connection produced by the selected transport parameterization using the given loop options, then closes the upgraded connection automatically.
staticrun_session(Connection,Handler,State,Options)run_session(+compound,+object_identifier,-compound,+list) - one_or_errorConnection is a variable:instantiation_errorConnection is not a valid upgraded WebSocket connection handle:domain_error(http_socket_transport_connection,Connection)Handler is a variable:instantiation_errorHandler is not a valid WebSocket service handler:domain_error(http_websocket_service_handler,Handler)Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Option of the list Options is neither a variable nor a compound term:type_error(compound,Option)Option of the list Options is a compound term but not a valid option:domain_error(option,Option)Options contains an invalid WebSocket service loop option:domain_error(http_websocket_service_option,Option)existence_error(http_websocket_service,timing)client nor server:domain_error(http_websocket_session_role,_Role_)domain_error(http_websocket_session_sequence,Frame)domain_error(http_websocket_session_masking,Frame)domain_error(http_websocket_session_extensions,Frame)domain_error(http_websocket_frame,Frame)domain_error(http_websocket_message_text,Payload)Handler returns a variable reply list:instantiation_errorHandler returns a non-list reply list:type_error(list,Replies)Handler returns an invalid reply:domain_error(http_websocket_service_handler_reply,Reply)
Option
auto_pong(on): Automatically writes pong replies while still forwarding ping messages to the handler.Option
auto_pong(off): Disables automatic pong replies. This is the default.Option
keepalive_interval(Seconds): When no inbound message is received for the given positive number of seconds, writes an empty ping message and continues the loop. This option requires backend thread support.Option
idle_timeout(Seconds): When no inbound message is received for the given positive number of seconds, writesmessage(close, status(1001, idle_timeout))and waits up to one additional idle-timeout interval for the peer to complete the close handshake before stopping. This option requires backend thread support.Option
max_payload_length(Bytes): Rejects inbound frames whose declared payload length is greater thanBytesbefore allocating payload storage. Oversized frames are treated as1009close errors in the session loop. Use a non-negative integer.
Protected predicates
run_session_connection/5
Protected helper that runs the callback-driven session loop on an upgraded WebSocket connection starting from the given session state and using the given loop options. Connection ownership is handled by the caller.
staticrun_session_connection(Connection,HandlerDescriptor,State,UpdatedState,Options)run_session_connection(+compound,+compound,+compound,-compound,+list) - one_or_errorConnection is a variable:instantiation_errorConnection is not a valid upgraded WebSocket connection handle:domain_error(http_socket_transport_connection,Connection)HandlerDescriptor is not a valid WebSocket service handler descriptor:domain_error(http_websocket_service_handler,HandlerDescriptor)HandlerDescriptor is a variable:instantiation_errorHandlerDescriptor is not a valid WebSocket service handler:domain_error(http_websocket_service_handler,Handler)State is a variable:instantiation_errorState is not a valid WebSocket session state:domain_error(http_websocket_session_state,State)Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Option of the list Options is neither a variable nor a compound term:type_error(compound,Option)Option of the list Options is a compound term but not a valid option:domain_error(option,Option)Options contains an invalid WebSocket service loop option:domain_error(http_websocket_service_option,Option)existence_error(http_websocket_service,timing)client nor server:domain_error(http_websocket_session_role,_Role_)domain_error(http_websocket_session_sequence,Frame)domain_error(http_websocket_session_masking,Frame)domain_error(http_websocket_session_extensions,Frame)domain_error(http_websocket_frame,Frame)domain_error(http_websocket_message_text,Payload)instantiation_errortype_error(list,Replies)type_error(list,Actions)domain_error(http_websocket_service_handler_reply,Reply)domain_error(http_websocket_service_handler_action,Action)HandlerDescriptor is not an open WebSocket service registry handle:domain_error(http_websocket_service_registry,Registry)HandlerDescriptor is not a valid WebSocket service registry session handle:domain_error(http_websocket_service_registry_session,Session)HandlerDescriptor is not registered in the registry:existence_error(http_websocket_service_registry_session,websocket_session(RegistryId,SessionId))validate_non_negative_integer_option/4
Validates a non-negative integer option value for the given domain and option name.
staticvalidate_non_negative_integer_option(Domain,Name,Value,ValidatedValue)validate_non_negative_integer_option(+atom,+atom,@term,-integer) - one_or_errorValue is not a non-negative integer option value for the given domain and option name:domain_error(Domain,Option)Private predicates
(no local declarations; see entity ancestors if any)
Operators
(none)