
SignalR & Real-time
SignalR hubs, WebSockets, Server-Sent Events, connection management, scaling, performance
1What is a Hub in SignalR?
What is a Hub in SignalR?
답변
A Hub is a class that serves as the central communication point between the server and connected clients. It allows invoking methods on the client side from the server and vice versa. Hubs automatically handle connection, disconnection, and message routing between connected clients. They inherit from the Hub class provided by SignalR and expose public methods that clients can call.
2How to create a strongly-typed Hub in SignalR?
How to create a strongly-typed Hub in SignalR?
답변
A strongly-typed Hub inherits from Hub<T> where T is an interface defining client methods. This provides IntelliSense and type checking when calling client methods via Clients.All, Clients.Caller, etc. The interface defines the contract of methods the server can invoke on clients. This approach reduces runtime errors by catching typing issues at compile time.
3What is the difference between Clients.All and Clients.Others in a SignalR Hub?
What is the difference between Clients.All and Clients.Others in a SignalR Hub?
답변
Clients.All sends the message to all connected clients, including the client that triggered the call. Clients.Others excludes the calling client and only sends the message to other connected clients. Using Clients.Others is useful for scenarios like broadcasting notifications where the emitting client doesn't need to receive its own message. Clients.Caller allows sending only to the calling client.
How to manage groups in SignalR to send messages to a subset of clients?
What transports are supported by SignalR and in what order are they negotiated?
+19 면접 질문