Setting Up WebSockets in Intrexx

Create a topic

Topics are created in the "Applications" module.

Step-by-Step

To create a topic in an application, follow these steps:

  1. Open the properties of the application in which you want to create the topic. You can access the properties via the application node.

  2. Go to the "Topics" tab.

  3. Click the " " icon.

    The "Topic GUID" and "Topic Name" fields are displayed in the right-hand pane of the dialog box.

    GUID of the topic

    The GUID of the topic is displayed in the right-hand pane of the dialog box. The GUID is automatically assigned by Intrexx and cannot be changed. You'll need the GUID if you want to reference this topic in a Groovy action or in JavaScript.

    Topic Name

    Enter a name for the topic. The topic name must be unique. It may appear only once in Intrexx. You can use the topic name if you want to refer to the topic in WebSocket actions.

  4. (Optional) Click the " " icon again to add more topics.

    You can add as many topics as you like to an application.

    You have created a topic in an application.

Include JavaScript for WebSockets in the Application

Step-by-Step

To configure JavaScript for WebSockets in an application, follow these steps:

  1. Launch the application in which you want to view the WebSocket message (the application that contains the topic you want to subscribe to using JavaScript).

  2. Launch the JavaScript editor (Ctrl + F12).

  3. Enter the JavaScript code.

    a. Implement the functionality for subscribing to the message and for displaying the message in the portal.

    b. (Optional) Enter the function to unsubscribe.

  4. Define a (JavaScript) event that

    a. Subscription begins (e.g., onload, click)

    b. (Optional) the subscription is canceled.

Set Up a WebSocket Action

WebSocket actions are configured in the "Processes" module.

Prerequisites/Preparatory Work

Add a WebSocket action to the corresponding process as usual.

Step-by-Step

To set up a WebSocket action, follow these steps:

  1. Open the properties of the WebSocket action.

  2. Enter a title and (optional) a description for the WebSocket action.

  3. Go to the "Topic" tab.

  4. From the "Application" drop-down list, select the application to which the message should be sent.

  5. From the "Topic" drop-down list, select the topic to which the message should be sent.
    The topic can be subscribed to by the browser. For more information, see sections 2. Create a topic: and 3. Set the display in the portal:.

    Note: When using a WebSocket action, simply specifying the name of a topic is sufficient to reference it.

    When using a Groovy action, you need the topic's GUID to reference it.

    Send a message after the transaction is committed

    Use this checkbox to control whether the message should be sent after the transaction is successfully completed (commit) or even if the transaction was rolled back.

  6. Go to the "Content" tab.

  7. Summarize the content of the message.

    You have the following options available to you:

    Static Text

    Here you can enter static text. This is useful when the message remains the same, for example, when certain parts of the message need to be updated.

    Text from data field

    To dynamically display text, you can select a data field here that provides the values. This option is available only if you are using a data group event handler in the process.

    Text from system value

    Here you can generate text based on system values. For example, you can retrieve user values or variables from the processing context.

    Generate from Velocity

    Here you can generate text using a Velocity script.

  8. Go to the "Exception Handling" tab.

    Specify how Intrexx should respond if no (message) content can be found for further processing.
    You have the following options available to you:

    Cancel Transaction (Default)

    If you select this option, the transaction will be canceled. In other words, the process will not continue if the WebSocket action does not contain any content. In this case, no message is sent to the associated topic.

    Continue the transaction

    If you select this option, the transaction will continue. Select this option if you want downstream process actions to continue even if the WebSocket action does not contain any content. This option may also be useful if you want to save the record that triggers the event.

  9. Click "OK."

    You have set up a WebSocket action.

Set Up a Groovy Campaign

Groovy actions are set up in the "Processes" module.

Prerequisites/Preparatory Work

Add a Groovy action to the corresponding process as usual.

Step-by-Step

To set up a Groovy action with WebSocket functionality, follow these steps:

  1. Open the properties of the Groovy action.

  2. Go to the "Script" tab.

  3. Click "Open Intrexx Editor."

    The Intrexx Editor launches.

  4. Enter the Groovy script.

    Use the Groovy script to create the WebSocket message and establish the connection to the topic.

  5. Import the Groovy script class:

    en.uplanet.lucy.server.websocket.groovy.GroovyWebSocketTopic

  6. Use the following function to send text messages:

    GroovyWebSocketTopic.sendTextMessage

    GroovyWebSocketTopic.sendJsonMessage