Component Operation with websocket connection

Table of Contents

Description

Performs one of the operations on the websocket connection of a user of the system or an external system. The connection must exist and be active.
The connection identifier is generated by the websocket connection processing module in the ws role and placed in registrar (sr role) after authorization.

It is possible to send asynchronous messages to a connection, send requests and receive responses. Plugin methods are supported. Two-way file sharing using HTTP is available, as well as providing public temporary links to files via the HTTP.

Table 1. System Characteristics

Index

144

Short title

websock

Types of scenarios

All of them

Starter module

r_script_component_websock

Mode

Asynchronous

Icon

144

Branching pattern

Branching, closing

Properties

Table 2. Properties
Specification Description

Title: Operation
Code: operation
Visibility: no
Default: Send

Select an operation from the list.
Possible options:

  • Send Message (sendtokenmsg, 0) - Sends a message to the specified websocket connection.

  • Place a file for download (ws_temp_file, 1) - Places the specified file on the webserver serving the specified websocket connection. The file is given a random name and the component returns a relative URL. The file is temporarily available for download via HTTP(s) without authorization for 5 minutes.

  • Files websocktemp (websocktemp, 2) - Performs one of the file sharing actions with a temporary session directory on the webserver serving the specified websocket connection (websocktemp category). The files are available to external applications authorized under the system user account in the same session as the specified websocket connection. Files are available through API.

Title: Connection ID
Code: conn
Visibility: no
Default: — 

The identifier of the active websocket connection. The connection can be established by an external system with any of the web servers in the deployed cluster, even at a different site.
The identifier is a long string and can be obtained from REGISTRAR service by searching by user and API extension name (capability), or as a parameter of the script processing incoming connections.

Title: Destination
Code: direction
Visibility: no
Default: Token message

Select a direction from the list.
Possible options:

  • Token message (token message, 0) – Sends a message with the message code through an API extension to serve websocket connections from external systems.

  • Token plugin event (token plugin event, 1) – Sends a message with the specified code through the specified API extension to serve websocket connections from external systems.

  • User API event (user api event, 2) – Sends a message with the specified code through the specified API extension to serve custom websocket connections.

Title: Extension name API
Code: capabilityName
Visibility: yes
Default: — 

Name of the API extension through which the specified message is sent. It can be either a standard module or any connected plugin-module of the system that implements the program interface for sending messages of the specified type.

Title: Message code
Code: eventName
Visibility: yes
Default: — 

The code of the message sent via the specified API extension. Substituted as the first element of a JSON array representing a message in the protocol websocket.
Depending on the way this particular message code is implemented in the API extension, an asynchronous message that does not require a response or a synchronous request can be sent. In this case, if the option of waiting for delivery/response is selected, it is possible to receive data from the remote system along with the response.

Title: Message Body
Code: content
Visibility: yes
Default: — 

Message body. Must conform to JSON format, unless otherwise defined by a specific extension API.

Title: Waiting for delivery/response
Code: syncMode
Visibility: yes
Default: No

Switch on synchronous mode of waiting for message delivery to the destination application. If the selected message code within the API extension is a request, enabling the mode provides for receiving a response and saving it to the specified variable.

Title: File path
Code: filePath
Visibility: yes
Default: — 

Special file path available to the script handler.
Applies to the operation of placing a file on a webserver.

Title: Action
Code: websocktempMethod
Visibility: yes
Default: `Get file list'

Select an action from the list as part of a file sharing operation with the session’s temporary directory on the webserver serving the specified connection (category websocktemp).
Possible options:

  • Get file list (get_coll, 0) - Returns a list of files in the websocktemp webserver temporary directory.

  • Get file (get_file, 1) - Fetches the file specified by name from the websocktemp webserver temporary directory and saves it in the temporary directory of the current script.

  • Place file (put_file, 2) - Places a file in the websocktemp webserver temporary directory. The file is taken from a special path available to the script handler.

  • Delete file (delete_file, 3) - Deletes the file specified by name from the websocktemp webserver temporary directory.

Applies to a file operation with a category websocktemp.

Title: File path
Code: websocktempFilePath
Visibility: yes
Default: — 

Special file path available to the script handler.
Applies to a file operation with a category websocktemp.

Title: File Name
Code: websocktempFileName
Visibility: yes
Default: — 

File name for file sharing operations with a temporary directory on the connection’s web server under category websocktemp.
Applies to a file operation with a category websocktemp.

Title: Time, s
Code: timeoutSec
Visibility: yes
Default: — 

Timeout to wait for message delivery, in seconds.

Title: Result to variable
Code: resultVariable
Visibility: yes
Default: — 

Variable to store the content of the response to a sent request if delivery/response pending mode is selected and the selected message code is implemented in the specified API extension as a request format request.

Title: Error to variable
Code: errorVariable
Visibility: no
Default: — 

Variable to save the error.

Title: Transition
Code: transfer
Visibility: no
Default: — 

The component to which control is passed if the operation is successfully completed.

Title: Transition, Time
Code: transferTimeout
Visibility: no
Default: — 

The component to which control is passed when the timeout for waiting for message delivery expires.

Title: Transition, Error
Code: transferError
Visibility: no
Default: — 

The component to which control is passed if an error occurs.

See also