ASP.NET Core RC2 SignalR Hub Context outside request thread

后端 未结 3 2224
余生分开走
余生分开走 2020-12-02 21:01

I am currently trying out the RC2 release of ASP.NET Core and I am running into an issue with SignalR. I need to be able to send messa

3条回答
  •  醉梦人生
    2020-12-02 22:00

    Another possibility is to inject your HubContext into your controller like:

    public VarDesignCommController(IHubContext hubcontext)
    {
        HubContext = hubcontext;
        ...
    }
    
    private IHubContext HubContext
    {
        get;
        set;
    }
    

    Then you can also call

    await this.HubContext.Clients.All.InvokeAsync("Completed", id);
    

    But then you will direct call methods on all clients.

    See also Call SignalR Core Hub method from Controller for an other possibility

提交回复
热议问题