add Hub client interface

This commit is contained in:
chsakell
2016-10-10 09:42:43 +03:00
parent 149e093f16
commit b637f119c8
4 changed files with 14 additions and 5 deletions

View File

@@ -1,14 +1,15 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
using LiveGameFeed.Models;
namespace LiveGameFeed.Hubs
{
public class Broadcaster : Hub
public class Broadcaster : Hub<IBroadcaster>
{
public override Task OnConnected()
{
// Set connection id for just connected client only
return Clients.Client(Context.ConnectionId).setConnectionId(Context.ConnectionId);
return Clients.Client(Context.ConnectionId).SetConnectionId(Context.ConnectionId);
}
// Server side methods called from client
@@ -22,4 +23,12 @@ namespace LiveGameFeed.Hubs
return Groups.Remove(Context.ConnectionId, matchId.ToString());
}
}
public interface IBroadcaster
{
Task SetConnectionId(string connectionId);
Task UpdateMatch(MatchViewModel match);
Task AddFeed(FeedViewModel feed);
Task AddChatMessage(ChatMessage message);
}
}