mirror of
https://github.com/chsakell/aspnet-core-signalr-angular.git
synced 2025-12-23 01:37:59 +00:00
25 lines
696 B
C#
25 lines
696 B
C#
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace LiveGameFeed.Hubs
|
|
{
|
|
public class Broadcaster : Hub
|
|
{
|
|
public override Task OnConnected()
|
|
{
|
|
// Set connection id for just connected client only
|
|
return Clients.Client(Context.ConnectionId).setConnectionId(Context.ConnectionId);
|
|
}
|
|
|
|
// Server side methods called from client
|
|
public Task Subscribe(int matchId)
|
|
{
|
|
return Groups.Add(Context.ConnectionId, matchId.ToString());
|
|
}
|
|
|
|
public Task Unsubscribe(int matchId)
|
|
{
|
|
return Groups.Remove(Context.ConnectionId, matchId.ToString());
|
|
}
|
|
}
|
|
} |