'webconstr' capability for WebSocket User API
Overview
The module serves the Web Constructor application, designed to create an interactive User Interface.
The Web Constructor in its pure form is packaged into a role application archive, where the event processing flow is additionally described by metadata. Additionally, interaction scripts with instances of such role applications can be configured on the server.
Processing UI events in scripts
Each event generated in the UI can be configured to send a request to the server.
As a result of such a request, the service script assigned in the role application metadata is executed, and its result is an update for the application state. Applying the update to the UI state changes its appearance or fills it with content.
The script can be packaged together with the constructor into the role application archive and not be visible to users and the system administrator via the API.
Thus, the very initiating event - load - is executed during loading and serves to initially fill the UI with forms and content.
Requests to the server
Application event (send_app_event)
Starts the service script assigned to the event data.name in the role application metadata (event-scripts, otherwise script, otherwise the role application script). The script receives data, connection properties (role application, user, setup parameters), and the connection identifier.
Parameters:
-
data— event object, thenamefield is required; -
appPath— application path/app/<folder>, if not set insetup.
[
"send_app_event",
{
"qid":2,
"appPath":"/app/myapp",
"data":{"name":"load"}
}
]
["send_app_event_result", {"qid":2, "result":"ok", "data":{ ... }}]
Response data — the script result (application state update). On error — result: error and error.
Server-generated events
At a script’s initiative, the server can generate a state change for any user in any of their applications. Processing the server state change event leads to UI changes - the form, style, or content may change - up to complete UI replacement.
Connections from Web Constructor applications are discovered in the registrar using the Operation(Svc) and Operation(IVR) components. A filter by user and application name (folder) is specified. Distinguishing copies of the same application launched by one user must be handled in the script based on other user data.