Blame view

netcore/src/Infrastructure/NCC/InstantMessaging/IM.cs 1.19 KB
de2bd2f9   “wangming”   项目初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  using Microsoft.AspNetCore.SignalR;
  using System;
  
  namespace NCC.InstantMessaging
  {
      /// <summary>
      /// 即时通信静态类
      /// </summary>
      public static class IM
      {
          /// <summary>
          /// 获取集线器实例
          /// </summary>
          /// <typeparam name="THub"></typeparam>
          /// <param name="serviceProvider"></param>
          /// <returns></returns>
          public static IHubContext<THub> GetHub<THub>(IServiceProvider serviceProvider = default)
              where THub : Hub
          {
              return App.GetService<IHubContext<THub>>(serviceProvider);
          }
  
          /// <summary>
          /// 获取强类型集线器实例
          /// </summary>
          /// <typeparam name="THub"></typeparam>
          /// <typeparam name="TStronglyTyped"></typeparam>
          /// <param name="serviceProvider"></param>
          /// <returns></returns>
          public static IHubContext<THub, TStronglyTyped> GetHub<THub, TStronglyTyped>(IServiceProvider serviceProvider = default)
              where THub : Hub<TStronglyTyped>
              where TStronglyTyped : class
          {
              return App.GetService<IHubContext<THub, TStronglyTyped>>(serviceProvider);
          }
      }
  }