コード例 #1
0
        internal async Task SendToConnectionTest(ServiceTransportType serviceTransportType, string appName)
        {
            var testServer = _testServerFactory.Create(TestOutputHelper);
            await testServer.StartAsync(new Dictionary <string, string> {
                [TestStartup.ApplicationName] = appName
            });

            var task = testServer.HubConnectionManager.WaitForConnectionCountAsync(1);

            var receivedMessageDict = new ConcurrentDictionary <int, int>();

            var(clientEndpoint, clientAccessTokens, serviceHubContext) = await InitAsync(serviceTransportType, appName);

            try
            {
                await RunTestCore(clientEndpoint, clientAccessTokens,
                                  async() =>
                {
                    var connectionId = await task.OrTimeout();
                    await serviceHubContext.Clients.Client(connectionId).SendAsync(MethodName, Message);
                },
                                  1, receivedMessageDict);
            }
            finally
            {
                await serviceHubContext.DisposeAsync();
            }
        }
コード例 #2
0
        public async Task Call_NegotiateAsync_After_WithEndpoints(ServiceTransportType serviceTransportType)
        {
            var serviceManager = new ServiceManagerBuilder()
                                 .WithOptions(o =>
            {
                o.ServiceTransportType = serviceTransportType;
                o.ServiceEndpoints     = ServiceEndpoints;
            })
                                 .BuildServiceManager();
            var hubContext = await serviceManager.CreateHubContextAsync(Hub, default);

            for (var i = 0; i < 5; i++)
            {
                var randomEndpoint      = ServiceEndpoints[StaticRandom.Next(0, Count)];
                var negotiationResponse = await(hubContext as IInternalServiceHubContext)
                                          .WithEndpoints(new ServiceEndpoint[] { randomEndpoint })
                                          .NegotiateAsync();

                Assert.Equal(ClientEndpointUtils.GetExpectedClientEndpoint(Hub, null, randomEndpoint.Endpoint), negotiationResponse.Url);
                var tokenString   = negotiationResponse.AccessToken;
                var token         = JwtTokenHelper.JwtHandler.ReadJwtToken(tokenString);
                var expectedToken = JwtTokenHelper.GenerateJwtBearer(
                    ClientEndpointUtils.GetExpectedClientEndpoint(Hub, null, randomEndpoint.Endpoint),
                    ClaimsUtility.BuildJwtClaims(null, null, null), token.ValidTo, token.ValidFrom, token.ValidFrom, randomEndpoint.AccessKey);
                Assert.Equal(expectedToken, tokenString);
            }
        }
コード例 #3
0
        internal async Task BroadcastTest(ServiceTransportType serviceTransportType)
        {
            var serviceManager    = Utility.GenerateServiceManager(TestConfiguration.Instance.ConnectionString, serviceTransportType);
            var serviceHubContext = await serviceManager.CreateHubContextAsync(HubName);

            var clientEndpoint    = serviceManager.GetClientEndpoint(HubName);
            var clientAccessToken = serviceManager.GenerateClientAccessToken(HubName);

            var connections = await CreateAndStartClientConnections(clientEndpoint, clientAccessToken);

            var receivedMessageCount = 0;

            ListenOnMessage(connections, () => receivedMessageCount++);

            Task task = null;

            try
            {
                await(task = serviceHubContext.Clients.All.SendAsync(MethodName, Message));
            }
            finally
            {
                Assert.Null(task.Exception);
            }

            await Task.Delay(_timeout);

            Assert.Equal(ClientConnectionCount, receivedMessageCount);
        }
コード例 #4
0
        internal async Task ConnectionJoinLeaveGroupTest(ServiceTransportType serviceTransportType, string appName)
        {
            var testServer = _testServerFactory.Create(TestOutputHelper);
            await testServer.StartAsync(new Dictionary <string, string> {
                [TestStartup.ApplicationName] = appName
            });

            var task = testServer.HubConnectionManager.WaitForConnectionCountAsync(1);

            var receivedMessageDict = new ConcurrentDictionary <int, int>();

            var(clientEndpoint, clientAccessTokens, serviceHubContext) = await InitAsync(serviceTransportType, appName);

            try
            {
                await RunTestCore(clientEndpoint, clientAccessTokens,
                                  async() =>
                {
                    var connectionId = await task.OrTimeout();
                    await serviceHubContext.Groups.AddToGroupAsync(connectionId, _groupNames[0]);
                    await serviceHubContext.Clients.Group(_groupNames[0]).SendAsync(MethodName, Message);
                    // We can't guarantee the order between the send group and the following leave group
                    await Task.Delay(_timeout);
                    await serviceHubContext.Groups.RemoveFromGroupAsync(connectionId, _groupNames[0]);
                    await serviceHubContext.Clients.Group(_groupNames[0]).SendAsync(MethodName, Message);
                },
                                  1, receivedMessageDict);
            }
            finally
            {
                await serviceHubContext.DisposeAsync();
            }
        }
コード例 #5
0
        internal async Task TestAddUserToGroupWithTtl(ServiceTransportType serviceTransportType, string appName)
        {
            var userNames  = GenerateRandomNames(ClientConnectionCount);
            var groupNames = GenerateRandomNames(GroupCount);

            var(clientEndpoint, clientAccessTokens, serviceHubContext) = await InitAsync(serviceTransportType, appName, userNames);

            try
            {
                var userGroupDict       = GenerateUserGroupDict(userNames, groupNames);
                var receivedMessageDict = new ConcurrentDictionary <int, int>();
                await RunTestCore(
                    clientEndpoint,
                    clientAccessTokens,
                    () => SendToGroupCore(serviceHubContext, userGroupDict, SendAsync, (c, d) => AddUserToGroupWithTtlAsync(c, d, TimeSpan.FromSeconds(10)), Empty),
                    (userNames.Length / groupNames.Length + userNames.Length % groupNames.Length) * 2,
                    receivedMessageDict);

                await Task.Delay(TimeSpan.FromSeconds(30));

                receivedMessageDict.Clear();
                await RunTestCore(
                    clientEndpoint,
                    clientAccessTokens,
                    () => SendToGroupCore(serviceHubContext, userGroupDict, SendAsync, Empty, Empty),
                    0,
                    receivedMessageDict);
            }
            finally
            {
                await serviceHubContext.DisposeAsync();
            }

            Task SendAsync() =>
            serviceHubContext.Clients.Group(groupNames[0]).SendAsync(MethodName, Message);
コード例 #6
0
 public void SetValueFromOptions(ServiceManagerOptions options)
 {
     ServiceEndpoints = options.ServiceEndpoints ?? (options.ServiceEndpoint != null
             ? (new ServiceEndpoint[] { options.ServiceEndpoint })
             : (new ServiceEndpoint[] { new ServiceEndpoint(options.ConnectionString) }));
     ApplicationName      = options.ApplicationName;
     ConnectionCount      = options.ConnectionCount;
     Proxy                = options.Proxy;
     ServiceTransportType = options.ServiceTransportType;
 }
コード例 #7
0
        /// <summary>
        /// Returns a string representation of this <see cref="SignalROptions"/> instance.
        /// </summary>
        string IOptionsFormatter.Format()
        {
            var options = new JObject
            {
                { nameof(ServiceEndpoints), JArray.FromObject(ServiceEndpoints.Select(e => e.ToString())) },
                { nameof(ServiceTransportType), ServiceTransportType.ToString() },
                { nameof(JsonObjectSerializer), JsonObjectSerializer?.GetType().FullName }
            };

            return(options.ToString(Formatting.Indented));
        }
コード例 #8
0
        //[InlineData(ServiceTransportType.Transient)] Not implemented yet
        public async Task StrongTypedHubContextCheckEndpointHealthWithMultiEndpoints(ServiceTransportType serviceTransportType)
        {
            var serviceManager = new ServiceManagerBuilder()
                                 .WithOptions(o =>
            {
                o.ServiceTransportType = serviceTransportType;
                o.ServiceEndpoints     = FakeEndpointUtils.GetFakeEndpoint(2).ToArray();
            })
                                 .WithLoggerFactory(_loggerFactory)
                                 .BuildServiceManager();
            var hubContext = await serviceManager.CreateHubContextAsync <IChat>("hubName", default);

            await Assert.ThrowsAsync <AzureSignalRNotConnectedException>(() => hubContext.NegotiateAsync().AsTask());
        }
コード例 #9
0
        internal async Task CreateServiceHubContextTest(ServiceTransportType serviceTransportType, bool useLoggerFacory, string appName, int connectionCount)
        {
            var serviceManager = new ServiceManager(new ServiceManagerOptions
            {
                ConnectionString     = _testConnectionString,
                ServiceTransportType = serviceTransportType,
                ApplicationName      = appName,
                ConnectionCount      = connectionCount
            }, null);

            using (var loggerFactory = useLoggerFacory ? (ILoggerFactory) new LoggerFactory() : NullLoggerFactory.Instance)
            {
                var hubContext = await serviceManager.CreateHubContextAsync(HubName, loggerFactory);
            }
        }
コード例 #10
0
        internal async Task SendToUsersTest(ServiceTransportType serviceTransportType)
        {
            var receivedMessageDict = new ConcurrentDictionary <int, int>();

            var(clientEndpoint, clientAccessTokens, serviceHubContext) = await InitAsync(serviceTransportType);

            try
            {
                await RunTestCore(clientEndpoint, clientAccessTokens, () => serviceHubContext.Clients.Users(_userNames).SendAsync(MethodName, Message), ClientConnectionCount, receivedMessageDict);
            }
            finally
            {
                await serviceHubContext.DisposeAsync();
            }
        }
コード例 #11
0
        internal async Task SendToGroupExceptTest(ServiceTransportType serviceTransportType, string appName)
        {
            var method = nameof(SendToGroupExceptTest);
            var msg    = Guid.NewGuid().ToString();
            var group  = nameof(SendToGroupExceptTest);

            using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
            {
                var logger         = loggerFactory.CreateLogger <ServiceHubContextE2EFacts>();
                var serviceManager = GenerateServiceManager(TestConfiguration.Instance.ConnectionString, serviceTransportType, appName);
                var hubContext     = await serviceManager.CreateHubContextAsync(HubName) as ServiceHubContextImpl;

                var connectionCount = 3;
                var tcsDict         = new ConcurrentDictionary <string, TaskCompletionSource>();
                logger.LogInformation($"Message is {msg}");
                var connections = await Task.WhenAll(Enumerable.Range(0, connectionCount).Select(async _ =>
                {
                    var negotiationResponse = await hubContext.NegotiateAsync(null, default);
                    var connection          = CreateHubConnection(negotiationResponse.Url, negotiationResponse.AccessToken);
                    await connection.StartAsync();
                    var src = new TaskCompletionSource();
                    tcsDict.TryAdd(connection.ConnectionId, src);
                    connection.On(method, (string receivedMsg) =>
                    {
                        logger.LogInformation($"Connection {connection.ConnectionId} received msg : {receivedMsg}");
                        if (receivedMsg == msg)
                        {
                            src.SetResult();
                        }
                    });
                    await hubContext.Groups.AddToGroupAsync(connection.ConnectionId, group);
                    return(connection);
                }));

                var excluded = connections.First().ConnectionId;
                await hubContext.Clients.GroupExcept(group, excluded).SendAsync(method, msg);

                // await included connections to receive msg
                await Task.WhenAll(tcsDict.Where(item => item.Key != excluded).Select(i => i.Value.Task)).OrTimeout();

                Assert.False(tcsDict[excluded].Task.IsCompleted);

                //clean
                await Task.WhenAll(connections.Select(conn => conn.DisposeAsync()));

                await hubContext.DisposeAsync();
            }
        }
コード例 #12
0
        internal async Task CreateServiceHubContextTest(ServiceTransportType serviceTransportType, bool useLoggerFacory, string appName, int connectionCount)
        {
            var context = new ServiceManagerContext
            {
                ServiceTransportType = serviceTransportType,
                ApplicationName      = appName,
                ConnectionCount      = connectionCount,
                ServiceEndpoints     = new ServiceEndpoint[] { new ServiceEndpoint(_testConnectionString) }
            };
            var serviceManager = new ServiceManager(context, new RestClientFactory(UserAgent));

            using (var loggerFactory = useLoggerFacory ? (ILoggerFactory) new LoggerFactory() : NullLoggerFactory.Instance)
            {
                var hubContext = await serviceManager.CreateHubContextAsync(HubName, loggerFactory);
            }
        }
コード例 #13
0
        public async Task HubContextNotCheckEndpointHealthWithSingleEndpoint(ServiceTransportType serviceTransportType)
        {
            var serviceManager = new ServiceManagerBuilder()
                                 .WithOptions(o =>
            {
                o.ServiceTransportType = serviceTransportType;
                o.ConnectionString     = FakeEndpointUtils.GetFakeConnectionString(1).First();
            })
                                 .WithLoggerFactory(_loggerFactory)
                                 .BuildServiceManager();
            var hubContext = await serviceManager.CreateHubContextAsync("hubName", default);

            var negotiateResponse = await hubContext.NegotiateAsync();

            Assert.NotNull(negotiateResponse);
        }
コード例 #14
0
        internal async Task SendToGroupTest(ServiceTransportType serviceTransportType)
        {
            var receivedMessageDict = new ConcurrentDictionary <int, int>();

            var(clientEndpoint, clientAccessTokens, serviceHubContext) = await InitAsync(serviceTransportType);

            try
            {
                Func <Task> sendTaskFunc = () => serviceHubContext.Clients.Group(_groupNames[0]).SendAsync(MethodName, Message);
                await RunTestCore(clientEndpoint, clientAccessTokens, () => SendToGroupCore(serviceHubContext, sendTaskFunc), _userNames.Length / _groupNames.Length + _userNames.Length % _groupNames.Length, receivedMessageDict);
            }
            finally
            {
                await serviceHubContext.DisposeAsync();
            }
        }
コード例 #15
0
        internal async Task CreateServiceHubContextTest(ServiceTransportType serviceTransportType, bool useLoggerFacory, string appName)
        {
            var serviceManager = new ServiceManager(new ServiceManagerOptions
            {
                ConnectionString     = _testConnectionString,
                ServiceTransportType = serviceTransportType,
                ApplicationName      = appName
            });

            LoggerFactory loggerFactory;

            using (loggerFactory = useLoggerFacory ? new LoggerFactory() : null)
            {
                var hubContext = await serviceManager.CreateHubContextAsync(HubName, loggerFactory);
            }
        }
コード例 #16
0
        internal async Task SendToUserTest(ServiceTransportType serviceTransportType, string appName)
        {
            var userNames           = GenerateRandomNames(ClientConnectionCount);
            var receivedMessageDict = new ConcurrentDictionary <int, int>();

            var(clientEndpoint, clientAccessTokens, serviceHubContext) = await InitAsync(serviceTransportType, appName, userNames);

            try
            {
                await RunTestCore(clientEndpoint, clientAccessTokens, () => serviceHubContext.Clients.User(userNames[0]).SendAsync(MethodName, Message), 1, receivedMessageDict);
            }
            finally
            {
                await serviceHubContext.DisposeAsync();
            }
        }
コード例 #17
0
        public async Task UserJoinGroup_Test(ServiceTransportType serviceTransportType)
        {
            Task testAction(ServiceHubContext hubContext) => hubContext.UserGroups.AddToGroupAsync(UserId, GroupName);

            void assertAction(Dictionary <HubServiceEndpoint, List <TestServiceConnection> > createdConnections)
            {
                foreach (var list in createdConnections.Values)
                {
                    var msg = (UserJoinGroupMessage)list.SelectMany(l => l.ReceivedMessages).Single();
                    Assert.Equal(UserId, msg.UserId);
                    Assert.Equal(GroupName, msg.GroupName);
                }
            }

            await MockConnectionTestAsync(serviceTransportType, testAction, assertAction);
        }
コード例 #18
0
        internal async Task SendToGroupsTest(ServiceTransportType serviceTransportType, string appName)
        {
            var receivedMessageDict = new ConcurrentDictionary <int, int>();

            var(clientEndpoint, clientAccessTokens, serviceHubContext) = await InitAsync(serviceTransportType, appName);

            try
            {
                Func <Task> sendTaskFunc = () => serviceHubContext.Clients.Groups(_groupNames).SendAsync(MethodName, Message);
                await RunTestCore(clientEndpoint, clientAccessTokens, () => SendToGroupCore(serviceHubContext, sendTaskFunc), ClientConnectionCount, receivedMessageDict);
            }
            finally
            {
                await serviceHubContext.DisposeAsync();
            }
        }
コード例 #19
0
        internal async Task CreateServiceHubContextTest(ServiceTransportType serviceTransportType, bool useLoggerFacory, string appName, int connectionCount)
        {
            var builder = new ServiceManagerBuilder()
                          .WithOptions(o =>
            {
                o.ServiceTransportType = serviceTransportType;
                o.ApplicationName      = appName;
                o.ConnectionCount      = connectionCount;
                o.ConnectionString     = _testConnectionString;
            });
            var serviceManager = builder.Build();

            using (var loggerFactory = useLoggerFacory ? (ILoggerFactory) new LoggerFactory() : NullLoggerFactory.Instance)
            {
                var hubContext = await serviceManager.CreateHubContextAsync(HubName, default);
            }
        }
コード例 #20
0
        public async Task UserLeaveAllGroup_Test(ServiceTransportType serviceTransportType)
        {
            var userId = "User";

            Task testAction(ServiceHubContext hubContext) => hubContext.UserGroups.RemoveFromAllGroupsAsync(userId);

            void assertAction(ConcurrentDictionary <HubServiceEndpoint, List <MessageVerifiableConnection> > createdConnections)
            {
                foreach (var list in createdConnections.Values)
                {
                    var msg = (UserLeaveGroupMessage)list.SelectMany(l => l.ReceivedMessages).Single();
                    Assert.Equal(userId, msg.UserId);
                    Assert.Null(msg.GroupName);
                }
            }

            await RunCoreAsync(serviceTransportType, testAction, assertAction);
        }
コード例 #21
0
        public async Task UserJoinGroupWithTTL_Test(ServiceTransportType serviceTransportType)
        {
            var ttl = TimeSpan.FromSeconds(1);

            Task testAction(ServiceHubContext hubContext) => hubContext.UserGroups.AddToGroupAsync(UserId, GroupName, ttl);

            void assertAction(ConcurrentDictionary <HubServiceEndpoint, List <MessageVerifiableConnection> > createdConnections)
            {
                foreach (var list in createdConnections.Values)
                {
                    var msg = (UserJoinGroupMessage)list.SelectMany(l => l.ReceivedMessages).Single();
                    Assert.Equal(UserId, msg.UserId);
                    Assert.Equal(GroupName, msg.GroupName);
                    Assert.Equal((int)ttl.TotalSeconds, msg.Ttl);
                }
            }

            await RunCoreAsync(serviceTransportType, testAction, assertAction);
        }
コード例 #22
0
        internal async Task SendToGroupTest(ServiceTransportType serviceTransportType, string appName)
        {
            var receivedMessageDict = new ConcurrentDictionary <int, int>();

            var(clientEndpoint, clientAccessTokens, serviceHubContext) = await InitAsync(serviceTransportType, appName);

            try
            {
                Func <Task> sendTaskFunc  = () => serviceHubContext.Clients.Group(_groupNames[0]).SendAsync(MethodName, Message);
                var         userGroupDict = GenerateUserGroupDict(_userNames, _groupNames);
                await RunTestCore(clientEndpoint, clientAccessTokens,
                                  () => SendToGroupCore(serviceHubContext, userGroupDict, sendTaskFunc, AddUserToGroupAsync, UserRemoveFromGroupsOneByOneAsync),
                                  _userNames.Length / _groupNames.Length + _userNames.Length % _groupNames.Length, receivedMessageDict);
            }
            finally
            {
                await serviceHubContext.DisposeAsync();
            }
        }
コード例 #23
0
        public async Task UserLeaveGroup_Test(ServiceTransportType serviceTransportType)
        {
            var userId = "User";
            var group  = "Group";

            Task testAction(ServiceHubContext hubContext) => hubContext.UserGroups.RemoveFromGroupAsync(userId, group);

            void assertAction(Dictionary <HubServiceEndpoint, List <TestServiceConnection> > createdConnections)
            {
                foreach (var list in createdConnections.Values)
                {
                    var msg = (UserLeaveGroupMessage)list.SelectMany(l => l.ReceivedMessages).Single();
                    Assert.Equal(userId, msg.UserId);
                    Assert.Equal(group, msg.GroupName);
                }
            }

            await MockConnectionTestAsync(serviceTransportType, testAction, assertAction);
        }
コード例 #24
0
        private async Task RunCoreAsync(ServiceTransportType serviceTransportType, Func <ServiceHubContext, Task> testAction, Action <ConcurrentDictionary <HubServiceEndpoint, List <MessageVerifiableConnection> > > assertAction)
        {
            using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
            {
                var connectionFactory = new TestServiceConnectionFactory();
                var hubContext        = await new ServiceHubContextBuilder()
                                        .WithOptions(o =>
                {
                    o.ServiceTransportType = serviceTransportType;
                    o.ServiceEndpoints     = ServiceEndpoints;
                })
                                        .WithLoggerFactory(loggerFactory)
                                        .ConfigureServices(services => services.AddSingleton <IServiceConnectionFactory>(connectionFactory))
                                        .CreateAsync(Hub, default);

                await testAction.Invoke(hubContext);

                var createdConnections = connectionFactory.CreatedConnections;
                assertAction.Invoke(createdConnections);
            }
        }
コード例 #25
0
        internal async Task RemoveUserFromAllGroupsTest(ServiceTransportType serviceTransportType, string appName)
        {
            var receivedMessageDict = new ConcurrentDictionary <int, int>();

            var(clientEndpoint, clientAccessTokens, serviceHubContext) = await InitAsync(serviceTransportType, appName);

            try
            {
                Func <Task> sendTaskFunc  = () => serviceHubContext.Clients.Groups(_groupNames).SendAsync(MethodName, Message);
                var         userGroupDict = new Dictionary <string, List <string> > {
                    { _userNames[0], _groupNames.ToList() }
                };
                await RunTestCore(clientEndpoint, clientAccessTokens,
                                  () => SendToGroupCore(serviceHubContext, userGroupDict, sendTaskFunc, AddUserToGroupAsync, UserRemoveFromAllGroupsAsync),
                                  _groupNames.Length, receivedMessageDict);
            }
            finally
            {
                await serviceHubContext.DisposeAsync();
            }
        }
コード例 #26
0
        private async Task MockConnectionTestAsync(ServiceTransportType serviceTransportType, Func <ServiceHubContext, Task> testAction, Action <Dictionary <HubServiceEndpoint, List <TestServiceConnection> > > assertAction)
        {
            using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
            {
                var connectionFactory = new TestServiceConnectionFactory();
                var hubContext        = await new ServiceHubContextBuilder()
                                        .WithOptions(o =>
                {
                    o.ServiceTransportType = serviceTransportType;
                    o.ServiceEndpoints     = ServiceEndpoints;
                })
                                        .WithLoggerFactory(loggerFactory)
                                        .ConfigureServices(services => services.AddSingleton <IServiceConnectionFactory>(connectionFactory))
                                        .CreateAsync(Hub, default);

                await testAction.Invoke(hubContext);

                var createdConnections = connectionFactory.CreatedConnections.ToDictionary(p => p.Key, p => p.Value.Select(conn => conn as TestServiceConnection).ToList());
                assertAction.Invoke(createdConnections);
            }
        }
コード例 #27
0
        private static IServiceManager GenerateServiceManager(string connectionString, ServiceTransportType serviceTransportType = ServiceTransportType.Transient, string appName = null)
        {
            var serviceManager = new ServiceManagerBuilder()
                                 .WithOptions(opt =>
            {
                opt.ConnectionString     = connectionString;
                opt.ServiceTransportType = serviceTransportType;
                opt.ApplicationName      = appName;
            })
                                 .WithCallingAssembly()
                                 .Build();

            return(serviceManager);
        }
コード例 #28
0
        private static IServiceManager GenerateServiceManager(string connectionString, ServiceTransportType serviceTransportType = ServiceTransportType.Transient)
        {
            var serviceManagerOptions = new ServiceManagerOptions
            {
                ConnectionString     = connectionString,
                ServiceTransportType = serviceTransportType
            };

            return(new ServiceManager(serviceManagerOptions));
        }
コード例 #29
0
        private async Task <(string ClientEndpoint, IEnumerable <string> ClientAccessTokens, IServiceHubContext ServiceHubContext)> InitAsync(ServiceTransportType serviceTransportType)
        {
            using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
            {
                var serviceManager    = GenerateServiceManager(TestConfiguration.Instance.ConnectionString, serviceTransportType);
                var serviceHubContext = await serviceManager.CreateHubContextAsync(HubName, loggerFactory);

                var clientEndpoint     = serviceManager.GetClientEndpoint(HubName);
                var clientAccessTokens = from userName in _userNames
                                         select serviceManager.GenerateClientAccessToken(HubName, userName);

                return(clientEndpoint, clientAccessTokens.ToArray(), serviceHubContext);
            }
        }
コード例 #30
0
        private static IServiceManager GenerateServiceManager(string connectionString, ServiceTransportType serviceTransportType = ServiceTransportType.Transient, string appName = null)
        {
            var serviceManagerOptions = new ServiceManagerOptions
            {
                ConnectionString     = connectionString,
                ServiceTransportType = serviceTransportType,
                ApplicationName      = appName
            };

            return(new ServiceManager(serviceManagerOptions));
        }