Junior — Middle
Have you had experience using SignalR technology for real-time implementation in your projects?
sobes.tech AI
Answer from AI
Yes, I have experience using SignalR to implement real-time functionality in C# projects.
SignalR is a library for ASP.NET that simplifies adding real-time features, such as chat, notifications, and data updates without page reloads.
Example of using SignalR:
// Creating a hub
public class ChatHub : Hub
{
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
}
On the client side, you can subscribe to the "ReceiveMessage" event and update the UI in real-time.
SignalR automatically chooses the best transport (WebSocket, Server-Sent Events, Long Polling) depending on the client and server capabilities, which simplifies development.