mirror of
https://github.com/chsakell/aspnet-core-signalr-angular.git
synced 2025-12-22 17:27:48 +00:00
27 lines
728 B
C#
27 lines
728 B
C#
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace LiveGameFeed.Hubs
|
|
{
|
|
public class Broadcaster : Hub
|
|
{
|
|
public override Task OnConnected()
|
|
{
|
|
return Clients.All.userConnected("New connection " + Context.ConnectionId);
|
|
}
|
|
public Task Broadcast(string message)
|
|
{
|
|
return Clients.All.messageReceived(Context.ConnectionId + "> " + message);
|
|
}
|
|
|
|
public Task Subscribe(int matchId)
|
|
{
|
|
return Groups.Add(Context.ConnectionId, matchId.ToString());
|
|
}
|
|
|
|
public Task Unsubscribe(int matchId)
|
|
{
|
|
return Groups.Remove(Context.ConnectionId, matchId.ToString());
|
|
}
|
|
}
|
|
} |