Table of Contents

Class UciHub

Namespace
adas_core.WebSocket.Hubs
Assembly
adas-core.dll
public class UciHub : Hub, IDisposable
Inheritance
UciHub
Implements
Inherited Members
Extension Methods

Constructors

UciHub(IClientMessageService, ISubscribersService, ISubscriberGroupedService)

public UciHub(IClientMessageService clientMessageService, ISubscribersService subscribersService, ISubscriberGroupedService subscriberGroupedService)

Parameters

clientMessageService IClientMessageService
subscribersService ISubscribersService
subscriberGroupedService ISubscriberGroupedService

Methods

OnChatMessage(string)

Handles incoming chat messages received via the SignalR hub. Deserializes the payload into a Message instance and delegates processing to the client message service, logging and ignoring malformed payloads or unexpected errors.

[HubMethodName("chatMessage")]
public Task OnChatMessage(string message)

Parameters

message string

The raw JSON payload of the chat message sent by the client.

Returns

Task

OnConnectedAsync()

Handles a new SignalR hub connection by registering the connection as a subscriber, removing any prior subscriber that shares the same connection id to avoid duplicates on reconnection, and then invoking the base connection handler. Any exception encountered during processing is logged and surfaced as a failed task.

public override Task OnConnectedAsync()

Returns

Task

OnDisconnectedAsync(Exception?)

Handles the disconnection of a SignalR client by logging the disconnection cause and cleaning up the connection from grouped subscribers and the main subscribers service. Errors are logged as errors when an exception is provided, while normal disconnections are logged at debug level.

public override Task OnDisconnectedAsync(Exception? exception)

Parameters

exception Exception

The exception that caused the disconnection, or null when the disconnection was not caused by an error.

Returns

Task

OnSubscribe(string)

Handles a SignalR subscribe request by deserializing the incoming message, updating the subscriber information associated with the current connection, and forwarding the message for processing. Logs a warning and exits if the message cannot be deserialized or if the connection is unknown; any exception thrown during processing is caught and logged without rethrowing.

[HubMethodName("subscribe")]
public Task OnSubscribe(string subMessage)

Parameters

subMessage string

The raw JSON payload received from the client representing the subscription request.

Returns

Task

UnSubscribe()

Unsubscribes the current SignalR client by removing its connection from the subscribers service. Logs and swallows any error encountered during connection removal.

[HubMethodName("unsubscribe")]
public void UnSubscribe()