Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Integration Service

SignalRPubSubClient

  • Last UpdatedJul 27, 2026
  • 2 minute read

Namespace: AVEVA.IntegrationService.DataAPI.SDK.ApiClient

Interface: ISignalRPubSubClient

Description: SignalRPubSubClient is used for real-time communication with the Pub/Sub hub to subscribe/unsubscribe and listen to messages.

Methods

Subscribe

Subscribes to a specific topic to receive messages.

Signature:

Task<string> Subscribe(string topic)

Example:

using AVEVA.IntegrationService.DataAPI.SDK.ApiClient;

using AVEVA.IntegrationService.DataAPI.SDK.Event;

// Get or create SignalR client

var signalRClient = await SignalRHubConnectionFactory.CreatePubSubClient(

httpClientFactory,

hubConnectionManager,

AuthenticationType.Connect,

"https://api.mycompany.com/integration/v1",

accessToken

);

// Subscribe to message events

signalRClient.MessagePublished += OnMessageReceived;

// Subscribe to topic

string result = await signalRClient.Subscribe("MyDataSource");

Console.WriteLine($"Subscribed to topic: {result}");

// Event handler

void OnMessageReceived(object sender, PubSubMessageEventArgs e)

{

Console.WriteLine($"Message received from topic: {e.Topic}");

Console.WriteLine($"AckId: {e.Message.AckId}");

Console.WriteLine($"Context: {e.Message.Context}");

}

Unsubscribe

Unsubscribes from a specific topic.

Signature:

Task<string> Unsubscribe(string topic)

Example:

// Unsubscribe from topic

string result = await signalRClient.Unsubscribe("MyDataSource");

Console.WriteLine($"Unsubscribed from topic: {result}");

// Remove event handler

signalRClient.MessagePublished -= OnMessageReceived;

Publish

Publishes a message to a specific topic.

Signature:

Task<string> Publish(PubSubMessage publishObject, string topic)

Example:

using AVEVA.IntegrationService.DataAPI.SDK.Models;

// Create message to publish

var message = new PubSubMessage

{

AckId = "custom-ack-12345",

Context = "{\"Type\":\"Notification\",\"Severity\":\"High\"}",

Data = "Custom data payload"

};

// Publish message

string result = await signalRClient.Publish(message, "NotificationTopic");

Console.WriteLine($"Message published: {result}");

UpdateToken

Updates the authentication token for the SignalR connection.

Signature:

void UpdateToken(string token)

Example:

// Update token when it's refreshed

string newToken = await GetNewAccessToken();

signalRClient.UpdateToken(newToken);

Console.WriteLine("SignalR token updated");

RegisterTokenRefreshHandler

Registers a handler to automatically refresh tokens.

Signature:

void RegisterTokenRefreshHandler(Func<Task<string>> handler)

Example:

// Register token refresh handler

signalRClient.RegisterTokenRefreshHandler(async () =>

{

Console.WriteLine("Token refresh requested");

string newToken = await RefreshAuthenticationToken();

return newToken;

});

async Task<string> RefreshAuthenticationToken()

{

// Your token refresh logic here

// For example, call your identity provider

var newToken = await identityService.RefreshTokenAsync();

return newToken;

}

MessagePublished Event

Event that fires when a message is published to a subscribed topic.

Example:

// Subscribe to message events with detailed processing

signalRClient.MessagePublished += (sender, e) =>

{

Console.WriteLine($"Message Published Event:");

Console.WriteLine($" Topic: {e.Topic}");

Console.WriteLine($" AckId: {e.Message.AckId}");

Console.WriteLine($" Context: {e.Message.Context}");

// Process based on context

if (e.Message.Context.Contains("Error"))

{

Console.WriteLine("Error notification received");

// Handle error

}

else if (e.Message.Context.Contains("Complete"))

{

Console.WriteLine("Completion notification received");

// Handle completion

}

};

Related Links