Class UciHub
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
clientMessageServiceIClientMessageServicesubscribersServiceISubscribersServicesubscriberGroupedServiceISubscriberGroupedService
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
messagestringThe raw JSON payload of the chat message sent by the client.
Returns
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
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
exceptionExceptionThe exception that caused the disconnection, or
nullwhen the disconnection was not caused by an error.
Returns
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
subMessagestringThe raw JSON payload received from the client representing the subscription request.
Returns
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()