azure-web-pubsub
Service icon

Azure Web PubSub

Stable version 1.3.0 (Compatible with OutSystems 11)
Uploaded
 on 29 November 2022
 by 
5.0
 (1 rating)
azure-web-pubsub

Azure Web PubSub

Documentation
1.0.1

This component connects your backend with Azure Web PubSub service.

  • Register an Azure Web PubSub service in Azure Portal. There is a free tier available.
  • Get either the primary or secondary connection string from the Keys section of your PubSub resource.


You need the connection string with all server actions.

To connect a frontend to Azure Web PubSub service please use the Azure Web PubSub Websocket library widget in your client application.

Note: Potentially you can use any WebSocket library available or just plain javascript as done is this library module.

  • Create a unique access Uri using the WebPubSub_GetClientAccessUri server action. The action returns an AccessUri which is the Url input parameter of the Websocket Widget of the Websocket library.


The WebPubSub_GetClientAccessUri has the following input parameters

  • ConnectionString - This is either the primary or secondary connection string from your PubSub resource key section.
  • Hub - Can be any text string. Think of hubs a message topics. A hub should have messages of a certain type.
  • UserId - here again any text string to identify the user of this connection. It makes sense to use GetUserId(). UserId can be used to target messages to a specific user.
  • TokenLifespan - A timespan in minutes on how long the access uri is valid. Defaults to 60 minutes.


Note: AccessUris are always unique and target a single Hub. Whenever a client needs to listen to multiple hubs - message topics - you have to create multiple access uris (one for each hub) and use multiple instances of the websocket widget.


  • Handle one or more events from the websocket widget. Especially the OnMessage event, which is fired whenever this client receives a message.


Sending messages from the backend

Messages in this component are just text strings, but it makes sense to send serialized data structures and deserialize them on the client again.

Send server actions are available for

  • WebPubSub_SendToUser - Sends a message to a specific user
  • WebPubSub_SendToGroup - Sends a message to all users of a given group
  • WebPubSub_SendToAll - Sends a message to every connected client.