1

In the old version we use GlobalHost like

var hubContext = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
hubContext.Clients.addNotification("Bla la la ");

But how to do it in the new alpha version ?

Halid
  • 448
  • 7
  • 16

1 Answers1

2

You need to inject IHubContext<THub> and then should be able to invoke methods.

class HubMethods
{
    private IHubContext<THub> _hubContext;
    public HubMethods(IHubContext<THub> hubContext)
    {
        _hubContext = hubContext;
    }

    public Task WriteMessageAsync(string method, param object[] args)
    {
        return _hubContext.Clients.All.InvokeAsync(method, args);
    }
}
Halid
  • 448
  • 7
  • 16