The connection identifier is generated by the websocket connection processing module in the ws role and is placed in registrar (sr role) after authorization.

Component Operation with websocket connection

:icons:font :hardbreaks: :imagesdir: ../../../assets/images :toc-title: Contents :toc:

Description

Performs one of the operations with a websocket connection of a system user or an external system. The connection must exist and be active. +\

It is possible to send asynchronous messages to the 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 HTTP.

Table 1. System characteristics

Index

144

Short name

websock

Script types

All

Start module

r_script_component_websock

Mode

Asynchronous

Icon

144

Branching type

Branching, closing

Properties

Table 2. Properties
Specification Description

Name: Operation

Code: operation

Visibility condition: no

Default: Send

Select an operation from the list.

Possible options:

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

  • Place file for download (ws_temp_file, 1) – Places the specified file on the web server 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.

  • websocktemp files (websocktemp, 2) - Performs one of the actions of exchanging files with the temporary session directory on the web server 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.

Name: Connection ID

Code: conn

Visibility condition: no

Default: — 

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

Name: Direction

Code: direction

Visibility condition: no

Default: Token message

Select a direction from the list.

Possible options:

  • Token message (token message, 0) – A message with code message is sent via the API extension for servicing 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 user websocket connections.

Name: API extension name

Code: capabilityName

Visibility condition: yes Default: — 

The name of the API extension through which the specified message is sent. This can be either a standard module or any connected system plug-in module that implements a software interface for sending messages of the specified type.

Name: Message code

Code: eventName

Visibility condition: yes

Default: — 

The code of the message sent through the specified API extension. Inserted as the first element of a JSON array representing a message in the websocket protocol.

Depending on how this particular message code is implemented in the API extension, an asynchronous message that does not require a response or a synchronous request may be sent. In this case, when you select the option to wait for delivery/response, it becomes possible to receive data from the remote system along with the response.

Name: Message body

Code: content

Visibility condition: yes

Default: — 

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

Name: Wait for delivery/response

Code: syncMode

Visibility condition: yes Default: No

Switch for synchronous waiting mode for message delivery to the recipient’s application. If the selected message code within the API extension is a request, then enabling the mode involves receiving a response and storing it in the specified variable.

Name: Path to file

Code: filePath

Visibility condition: yes

Default: — 

Special file path accessible to the script engine.

Used for the operation of placing a file on a web server.

Name: Action

Code: websocktempMethod

Visibility condition: yes

Default: Get a list of files

Select an action from the list as part of a file exchange operation with the temporary directory of the session on the web server serving the specified connection (websocktemp category).

Possible options:

  • Get list of files (get_coll, 0) – Returns a list of files in the webserver’s websocktemp temporary directory.

  • Get file (get_file, 1) – Gets the file specified by name from the websocktemp temporary directory of the web server and saves it in the temporary directory of the current script.

  • Place file (put_file, 2) – Places a file in the websocktemp temporary directory of the web server. The file is taken from a special path accessible to the script engine.

  • Delete file (delete_file, 3) – Deletes the file specified by name from the websocktemp temporary directory of the web server.

Used for file operation with category websocktemp.

Name: Path to file Code: websocktempFilePath Visibility condition: yes

Default: — 

Special file path accessible to the script engine.

Used for file operation with category websocktemp.

Name: File name

Code: websocktempFileName

Visibility condition: yes Default: — 

File name for performing file exchange operations with a temporary directory on the connection web server within the websocktemp category.

Used for file operation with category websocktemp.

Name: Time, s

Code: timeoutSec

Visibility condition: yes

Default: — 

Timeout for waiting for message delivery, in seconds.

Name: Result into variable

Code: resultVariable

Visibility condition: yes

Default: — 

Variable for storing the contents of the response to a sent request, if the delivery/response wait mode is selected and the selected message code is implemented in the specified API extension as a request request format.

Name: Error in variable

Code: errorVariable

Visibility condition: no Default: — 

Variable for storing the error.

Name: Transition

Code: transfer

Visibility condition: no

Default: — 

The component to which control is transferred if the operation completes successfully.

Name: Transition, time Code: transferTimeout Visibility condition: no

Default: — 

The component to which control is transferred if the timeout for waiting for message delivery expires.

Name: Transition, error

Code: transferError

Visibility condition: no

Default: — 

Component to which control is transferred in case of an error.

See also