Skip to main content

openWebSocket

Opens a WebSocket.

Field Configurations

KeyTypeDescriptionDefault Value
"params" (required)Objectundefinednull

Parameters

KeyTypeDescriptionDefault Value
"async"BooleanSpecifies whether the action should perform asynchronously.null
"background"Boolean,StringSpecifies whether the WebSocket should also be active in the background.false
"name" (required)StringName under which the WebSocket is available.null
"onClose"StringEvent that is fired after closing the connection.null
"onError"StringEvent that is fired in case of an error.null
"onMessage"StringEvent that is fired when a message is recieived.null
"onOpen"StringEvent that is fired on successfull conenction setup.null
"reconnect"Boolean,StringSpecifies whether the connection should be reconnected if an error occurs during transmisison.false
"url" (required)StringThe URL under which the WebSocket is located.null

Inherited

From Base Action

Base Action

Field Configurations

KeyTypeDescriptionDefault Value
"dynamicParams"ObjectDynamic params to retrieve data from a specific context e.g. a userSetting.null
"leadingDelimiter"StringThe leading mustache delimiter to use.null
"params"Object,ArrayObject containing the properties of the action.null
"trailingDelimiter"StringThe trailing mustache delimiter to use.null
"type"StringType name of the action.null

Examples

Example 1: Open a WebSocket

Goal: Create an openWebSocket action.

To achieve this the following code can be used:

{
"type": "openWebSocket",
"params": {
"name": "testSocket",
"url": "wss://demo.piesocket.com/v3/channel_1?api_key=oCdCMcMPQpbvNjUIzqtvF1d2X2okWpDQj4AwARJuAgtjhzKxVEjQU6IdCjwm&notify_self",
"background": true,
"onOpen": "openSocket",
"onMessage": "messageReceived",
"onError": "errorMessage",
"onClose": "closeSocket"
}
}

The onOpen, onMessage, onError and onClose parameters specifiy which events are to be fired when the respective criteria are met.

Result:

An openWebSocket action has been created.