.NET

SignalR & Real-time

SignalR hubs, WebSockets, Server-Sent Events, connection management, scaling, performance

22 питань зі співбесід·
Senior
1

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.

2

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.

3

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.

4

How to manage groups in SignalR to send messages to a subset of clients?

5

What transports are supported by SignalR and in what order are they negotiated?

+19 питань зі співбесід

Опануй .NET для наступної співбесіди

Отримай доступ до всіх питань, flashcards, технічних тестів, вправ code review та симуляторів співбесід.

Почни безкоштовно