4
4
5
5
namespace SignalR . Orleans . Core ;
6
6
7
- public class HubContext < THub >
7
+ public class HubContext < THub > : HubContext
8
8
{
9
- private readonly IGrainFactory _grainFactory ;
10
- private readonly string _hubName ;
9
+ public HubContext ( IGrainFactory grainFactory ) : base ( grainFactory , GetHubName ( ) )
10
+ {
11
+ }
11
12
12
- public HubContext ( IGrainFactory grainFactory )
13
+ public static string GetHubName ( )
13
14
{
14
- _grainFactory = grainFactory ;
15
15
var hubType = typeof ( THub ) ;
16
- _hubName = hubType . IsInterface && hubType . Name . StartsWith ( "I" )
16
+ return hubType . IsInterface && hubType . Name . StartsWith ( "I" )
17
17
? hubType . Name . Substring ( 1 )
18
18
: hubType . Name ;
19
19
}
20
+ }
21
+
22
+ public class HubContext
23
+ {
24
+ private readonly IGrainFactory _grainFactory ;
25
+
26
+ public string HubName { get ; init ; }
27
+
28
+ public HubContext ( IGrainFactory grainFactory , string hubName )
29
+ {
30
+ _grainFactory = grainFactory ;
31
+ HubName = hubName ;
32
+ }
20
33
21
- public IClientGrain Client ( string connectionId ) => _grainFactory . GetClientGrain ( _hubName , connectionId ) ;
22
- public IGroupGrain Group ( string groupName ) => _grainFactory . GetGroupGrain ( _hubName , groupName ) ;
23
- public IUserGrain User ( string userId ) => _grainFactory . GetUserGrain ( _hubName , userId ) ;
24
- }
34
+ public IClientGrain Client ( string connectionId ) => _grainFactory . GetClientGrain ( HubName , connectionId ) ;
35
+ public IGroupGrain Group ( string groupName ) => _grainFactory . GetGroupGrain ( HubName , groupName ) ;
36
+ public IUserGrain User ( string userId ) => _grainFactory . GetUserGrain ( HubName , userId ) ;
37
+ }
0 commit comments