Files
marqdo/ext/net/websocket.mq.md
T

2.9 KiB
Raw Blame History

markup, title, description, import
markup title description import
occlusion ext/net/websocket WebSocket client Resource (ADR 0007).
plugin sys table
lib/plugin.mq.md lib/sys.mq.md lib/table.mq.md

This resource performs one bounded native WebSocket exchange and closes it. The network entry shows the input contract and the distinction from pure URL encoding. Configure a controlled ws/wss endpoint and inspect ok/error, timeout and reply data before acting. New transport behavior belongs in the web plugin, with local tests for failed connections and oversized replies; this resource is not a persistent subscription service.

_load

返回 类型 说明
result any No business value on completion; a missing native plugin reports the cause and exits this run.

Resolve and load the native web plugin before resource operations; missing binaries stop this run.

We retain p = Locate the installed native plugin.

  1. p We Load the native plugin required by this operation.

We [Print the prepared message](print(text="ext/net: native web plugin not found")). We End this run with the selected exit status. Return None.

ws

参数 类型 默认 说明
timeout_sec any 30 Request/response timeout in seconds
返回 类型 说明
result any WebSocket client helper.

Use timeout_sec=30 as the inputs for this operation.

WebSocket client helper.

We Load the native plugin required by this operation.

out =

timeout_sec _type
timeout_sec ws

Return out.

connect

参数 类型 默认 说明
url any required Resource connection URL; scheme selects the documented backend
message any "" Outgoing WebSocket or application message
headers any None HTTP request header record or None
返回 类型 说明
result any Single request–response: connect to url, send message, collect up to 256 server text replies (each up to 1 MiB), close. Transport errors and timeouts return {ok:false, error} instead of looking like an empty successful reply.

Use url, message="", headers=None as the inputs for this operation.

Single request–response: connect to url, send message, collect up to 256 server text replies (each up to 1 MiB), close. Transport errors and timeouts return {ok:false, error} instead of looking like an empty successful reply.

We retain timeout = Read timeout_sec field). Return [Single request–response: connect to url, send message, collect up to 256 server text replies (each up to 1 MiB), close](web_ws_connect(url=url, message=message, headers=headers, timeout_sec=timeout)).