Yuari
Documentation
Docs/WebSocket/websocket_connect

websocket_connect

Legacy low-level WebSocket helpers that operate on a connection id.

Syntax

websocket_connect(url: string) -> any

Parameters

ParameterTypeDescription
urlstringThe target URL.

Returns

TypeDescription
anyThe value produced by the call.

Description

websocket_connect is part of the WebSocket library. WebSocket helpers manage a client connection: opening, sending, polling and closing, with message callbacks.

The operation is performed immediately using the arguments supplied at the call site.

The aliases websocket_send(id, message, binary?), websocket_poll(id), websocket_close(id) resolve to the same implementation.

Example

local id = websocket_connect("wss://echo.websocket.events")
websocket_send(id, "hello")
for _, message in ipairs(websocket_poll(id)) do
    print(message)
end
websocket_close(id)

Notes

  • Aliases: websocket_send(id, message, binary?), websocket_poll(id), websocket_close(id).
  • Keep message callbacks short; they run on the module's networking thread.