Try Install Learn Blog API Packages GitHub
Pages
Standard Library

Search
Entities

WebSocket

Functions

close
(
socket
:
WebSocket
)
:
Promise(Never, Void)

Closes the given websocket connection.

WebSocket.close(websocket)

If the reconnectOnClose flag was specified then the connection will reconnect using this function.

closeWithoutReconnecting
(
socket
:
WebSocket
)
:
Promise(Never, Void)

Closes the given websocket connection without reconnecting, even if the reconnectOnClose flag was set.

WebSocket.closeWithoutReconnecting(websocket)
open
(
config
:
WebSocket.Config
)
:
WebSocket

Creates a websocket connection from the given configuration:

websocket =
  WebSocket.open({
    url = "wss://echo.websocket.org",
    reconnectOnClose = true,
    onMessage = handleMessage,
    onError = handleError,
    onClose = handleClose,
    onOpen = handleOpen
  })

If reconnectOnClose is set then when a connection is closed it tries to reconnect, using the same configuration (basically calls open again).

send
(
data
:
String
socket
:
WebSocket
)
:
Promise(Never, Void)

Sends the given data to the given websocket connection.

WebSocket.send("some data", websocket)