openWebSocket
Opens a WebSocket.
Field Configurations
Key | Type | Description | Default Value |
---|---|---|---|
"params" (required) | Object | undefined | null |
Parameters
Key | Type | Description | Default Value |
---|---|---|---|
"async" | Boolean | Specifies whether the action should perform asynchronously. | null |
"background" | Boolean,String | Specifies whether the WebSocket should also be active in the background. | false |
"name" (required) | String | Name under which the WebSocket is available. | null |
"onClose" | String | Event that is fired after closing the connection. | null |
"onError" | String | Event that is fired in case of an error. | null |
"onMessage" | String | Event that is fired when a message is recieived. | null |
"onOpen" | String | Event that is fired on successfull conenction setup. | null |
"reconnect" | Boolean,String | Specifies whether the connection should be reconnected if an error occurs during transmisison. | false |
"url" (required) | String | The URL under which the WebSocket is located. | null |
Inherited
From Base Action
Base Action
Field Configurations
Key | Type | Description | Default Value |
---|---|---|---|
"dynamicParams" | Object | Dynamic params to retrieve data from a specific context e.g. a userSetting. | null |
"leadingDelimiter" | String | The leading mustache delimiter to use. | null |
"params" | Object,Array | Object containing the properties of the action. | null |
"trailingDelimiter" | String | The trailing mustache delimiter to use. | null |
"type" | String | Type 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¬ify_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.