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 ?
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 ?
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);
}
}