Login to follow
PubSub WebSocket

PubSub WebSocket (ODC)

Stable version 1.0.2 (Compatible with ODC)
Uploaded on 15 October 2025 by Nash Muylle
PubSub WebSocket

PubSub WebSocket (ODC)

Documentation
1.0.2

Prerequisites

  • An active Azure Web PubSub service instance.
  • Your HubName and PubSubConnectionString from Azure.

Step 1: Configure Site Settings

  1. In your OutSystems application, go to Site Properties.
  2. Add the following site properties:
    • HubName: Your Azure Web PubSub hub name.
    • PubSubConnectionString: Your Azure Web PubSub connection string.

Step 2: Add the PubSub Component to Your Page

  1. Drag the PubSub webblock onto your page.
  2. (Optional) If you want to control when the WebSocket connects, bind the WebSocketEnabled input to a boolean variable (default: False).

Step 3: Generate a Client Token

  1. Create a Data Action in your module.
  2. Use the GeneratePubSubClientTokenserver action.
    • Inputs: Use the HubName and PubSubConnectionString from your site settings.
    • (Optional) Set Expiration (default: 60 minutes).
  3. Assign the output to a variable (e.g., PubSubClientToken).
  4. Pass this variable to the PubSubClient input of the webblock.

Step 4: Send Messages

Use the following server actions to send messages:


SendToGroupOnClient

Send a message to a specific group

HubName, PubSubConnectionString, GroupName, Content, ContentType (text/plain or application/json)


SendToAllOnClient

Broadcast a message to all connected clients

HubName, PubSubConnectionString, Content, ContentType


SendToUserOnClient

Send a message to a specific user

HubName, PubSubConnectionString, UserId, Content, ContentType


Example:To send a message to a group:

  • Use SendToGroupOnClient.
  • Set GroupName to the same value used in your WebSocket connection.
  • Set ContentType to text/plain or application/json.

Notes

  • Ensure the GroupName used in SendToGroupOnClient matches the group your WebSocket client is subscribed to.
  • For security, always generate client tokens on the server side.