public async Task RemoveGroupAsync_ForConnection_OnDifferentServer_Works()
        {
            var manager1 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);
            var manager2 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);

            using (var client = new TestClient())
            {
                var output = Channel.CreateUnbounded <HubMessage>();

                var connection = new HubConnectionContext(output, client.Connection);

                await manager1.OnConnectedAsync(connection);

                await manager1.AddGroupAsync(connection.ConnectionId, "snoop");

                await manager2.InvokeGroupAsync("snoop", "Hello", new object[] { "World" });

                AssertMessage(output);

                await manager2.RemoveGroupAsync(connection.ConnectionId, "snoop");

                await manager2.InvokeGroupAsync("snoop", "Hello", new object[] { "World" });

                Assert.False(output.In.TryRead(out var item));
            }
        }
        public async Task InvokeAllAsync_ForSpecificHub_WithMultipleServers_WritesTo_AllConnections_Output()
        {
            var manager1 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);
            var manager2 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);
            var manager3 = new OrleansHubLifetimeManager <DifferentHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <DifferentHub> >(), this._fixture.Client);

            using (var client1 = new TestClient())
                using (var client2 = new TestClient())
                    using (var client3 = new TestClient())
                    {
                        var output1 = Channel.CreateUnbounded <HubMessage>();
                        var output2 = Channel.CreateUnbounded <HubMessage>();
                        var output3 = Channel.CreateUnbounded <HubMessage>();

                        var connection1 = new HubConnectionContext(output1, client1.Connection);
                        var connection2 = new HubConnectionContext(output2, client2.Connection);
                        var connection3 = new HubConnectionContext(output3, client3.Connection);

                        await manager1.OnConnectedAsync(connection1);

                        await manager2.OnConnectedAsync(connection2);

                        await manager3.OnConnectedAsync(connection3);

                        await manager1.InvokeAllAsync("Hello", new object[] { "World" });

                        AssertMessage(output1);
                        AssertMessage(output2);
                        Assert.False(output3.In.TryRead(out var item));
                    }
        }
        public async Task InvokeGroupAsync_WhenOneDisconnected_ShouldDeliverOthers()
        {
            using (var client1 = new TestClient())
                using (var client2 = new TestClient())
                    using (var client3 = new TestClient())
                    {
                        var manager     = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), _fixture.ClientProvider);
                        var connection1 = HubConnectionContextUtils.Create(client1.Connection);
                        var connection2 = HubConnectionContextUtils.Create(client2.Connection);
                        var connection3 = HubConnectionContextUtils.Create(client3.Connection);

                        await manager.OnConnectedAsync(connection1);

                        await manager.OnConnectedAsync(connection2);

                        var groupName = "gunit";
                        await manager.AddToGroupAsync(connection1.ConnectionId, groupName);

                        await manager.AddToGroupAsync(connection2.ConnectionId, groupName);

                        await manager.AddToGroupAsync(connection3.ConnectionId, groupName);

                        await manager.SendGroupAsync(groupName, "Hello", new object[] { "World" });

                        await AssertMessageAsync(client1);
                        await AssertMessageAsync(client2);
                    }
        }
        public async Task InvokeAsync_WhenNotConnectedAfterFailedAttemptsExceeds_ShouldForceDisconnect()
        {
            using (var client1 = new TestClient())
                using (var client2 = new TestClient())
                {
                    var manager     = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), _fixture.ClientProvider);
                    var connection1 = HubConnectionContextUtils.Create(client1.Connection);
                    var connection2 = HubConnectionContextUtils.Create(client2.Connection);

                    await manager.OnConnectedAsync(connection1);

                    var groupName = "flex";
                    await manager.AddToGroupAsync(connection1.ConnectionId, groupName);

                    await manager.AddToGroupAsync(connection2.ConnectionId, groupName);

                    await manager.SendGroupAsync(groupName, "Hello", new object[] { "World" });

                    var grain            = _fixture.ClientProvider.GetClient().GetGroupGrain("MyHub", groupName);
                    var connectionsCount = await grain.Count();

                    await AssertMessageAsync(client1);

                    Assert.Equal(2, connectionsCount);

                    await manager.SendGroupAsync(groupName, "Hello", new object[] { "World" });

                    await manager.SendGroupAsync(groupName, "Hello", new object[] { "World" });

                    connectionsCount = await grain.Count();

                    Assert.Equal(1, connectionsCount);
                }
        }
        public async Task InvokeAllAsync_ForSpecificHub_WithMultipleServers_WritesTo_AllConnections_Output()
        {
            var manager1 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);
            var manager2 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);
            var manager3 = new OrleansHubLifetimeManager <DifferentHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <DifferentHub> >(), this._fixture.ClientProvider);

            using (var client1 = new TestClient())
                using (var client2 = new TestClient())
                    using (var client3 = new TestClient())
                    {
                        var connection1 = HubConnectionContextUtils.Create(client1.Connection);
                        var connection2 = HubConnectionContextUtils.Create(client2.Connection);
                        var connection3 = HubConnectionContextUtils.Create(client3.Connection);

                        await manager1.OnConnectedAsync(connection1);

                        await manager2.OnConnectedAsync(connection2);

                        await manager3.OnConnectedAsync(connection3);

                        await manager1.SendAllAsync("Hello", new object[] { "World" });

                        await AssertMessageAsync(client1);
                        await AssertMessageAsync(client2);

                        Assert.Null(client3.TryRead());
                    }
        }
        public async Task InvokeGroupAsync_WritesTo_AllConnections_InGroup_Output()
        {
            using (var client1 = new TestClient())
                using (var client2 = new TestClient())
                {
                    var output1 = Channel.CreateUnbounded <HubMessage>();
                    var output2 = Channel.CreateUnbounded <HubMessage>();

                    var manager     = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);
                    var connection1 = new HubConnectionContext(output1, client1.Connection);
                    var connection2 = new HubConnectionContext(output2, client2.Connection);

                    await manager.OnConnectedAsync(connection1);

                    await manager.OnConnectedAsync(connection2);

                    await manager.AddGroupAsync(connection1.ConnectionId, "gunit");

                    await manager.InvokeGroupAsync("gunit", "Hello", new object[] { "World" });

                    AssertMessage(output1);

                    Assert.False(output2.In.TryRead(out var item));
                }
        }
        public async Task InvokeConnectionAsync_OnNonExistentConnection_DoesNotThrow()
        {
            var invalidConnection = "NotARealConnectionId";
            var grain             = this._fixture.Client.GetClientGrain("MyHub", invalidConnection);
            await grain.OnConnect(Guid.NewGuid(), "MyHub", invalidConnection);

            var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);
            await manager.InvokeConnectionAsync(invalidConnection, "Hello", new object[] { "World" });
        }
        public async Task RemoveGroup_FromLocalConnection_NotInGroup_DoesNothing()
        {
            var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);

            using (var client = new TestClient())
            {
                var connection = HubConnectionContextUtils.Create(client.Connection);

                await manager.OnConnectedAsync(connection);

                await manager.RemoveFromGroupAsync(connection.ConnectionId, "does-not-exists");
            }
        }
        public async Task InvokeConnectionAsync_WritesToConnection_Output()
        {
            using (var client = new TestClient())
            {
                var manager    = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);
                var connection = HubConnectionContextUtils.Create(client.Connection);

                await manager.OnConnectedAsync(connection);

                await manager.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" });

                await AssertMessageAsync(client);
            }
        }
        public async Task RemoveGroup_FromConnection_OnDifferentServer_NotInGroup_DoesNothing()
        {
            var manager1 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), _fixture.ClientProvider);
            var manager2 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), _fixture.ClientProvider);

            using (var client = new TestClient())
            {
                var connection = HubConnectionContextUtils.Create(client.Connection);

                await manager1.OnConnectedAsync(connection);

                await manager2.RemoveFromGroupAsync(connection.ConnectionId, "does-not-exist-server");
            }
        }
        public async Task RemoveGroup_FromLocalConnection_NotInGroup_DoesNothing()
        {
            var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);

            using (var client = new TestClient())
            {
                var output = Channel.CreateUnbounded <HubMessage>();

                var connection = new HubConnectionContext(output, client.Connection);

                await manager.OnConnectedAsync(connection);

                await manager.RemoveGroupAsync(connection.ConnectionId, "does-not-exists");
            }
        }
        public async Task InvokeConnectionAsync_WritesToConnection_Output()
        {
            using (var client = new TestClient())
            {
                var output     = Channel.CreateUnbounded <HubMessage>();
                var manager    = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);
                var connection = new HubConnectionContext(output, client.Connection);

                await manager.OnConnectedAsync(connection);

                await manager.InvokeConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" });

                AssertMessage(output);
            }
        }
        public async Task HubUsingGenericBase_NonInterfaceMatchingNaming_Output()
        {
            using (var client1 = new TestClient())
            {
                var manager = new OrleansHubLifetimeManager <DaHubUsingBase>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <DaHubUsingBase> >(), _fixture.ClientProvider);

                var connection1 = HubConnectionContextUtils.Create(client1.Connection);

                await manager.OnConnectedAsync(connection1).OrTimeout();

                await manager.SendAllAsync("Hello", new object[] { "World" }).OrTimeout();

                await AssertMessageAsync(client1);
            }
        }
        private async Task CreateManagerAsync(string managerId)
        {
            var options = new OrleansOptions <SampleHub>
            {
                ClusterClient = _testCluster.Client
            };

            var manager = new OrleansHubLifetimeManager <SampleHub>(Options.Create(options),
                                                                    new HubProxy <SampleHub>(options.ClusterClient),
                                                                    _loggerFactory.CreateLogger <OrleansHubLifetimeManager <SampleHub> >());

            managers[managerId] = manager;

            await Task.CompletedTask;
        }
        public async Task AddGroupAsync_ForConnection_OnDifferentServer_Works()
        {
            var manager1 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);
            var manager2 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);

            using (var client = new TestClient())
            {
                var connection = HubConnectionContextUtils.Create(client.Connection);

                await manager1.OnConnectedAsync(connection);

                await manager2.AddToGroupAsync(connection.ConnectionId, "ice-cube");

                await manager2.SendGroupAsync("ice-cube", "Hello", new object[] { "World" });

                await AssertMessageAsync(client);
            }
        }
        public async Task InvokeGroupAsync_OnServer_WithoutConnection_WritesOutputTo_GroupConnection()
        {
            var manager1 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);
            var manager2 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);

            using (var client = new TestClient())
            {
                var connection = HubConnectionContextUtils.Create(client.Connection);

                await manager1.OnConnectedAsync(connection);

                await manager1.AddToGroupAsync(connection.ConnectionId, "tupac");

                await manager2.SendGroupAsync("tupac", "Hello", new object[] { "World" });

                await AssertMessageAsync(client);
            }
        }
        public async Task InvokeConnectionAsync_WritesToConnections_Output()
        {
            using (var client1 = new TestClient())
                using (var client2 = new TestClient())
                {
                    var manager     = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), _fixture.ClientProvider);
                    var connection1 = HubConnectionContextUtils.Create(client1.Connection);
                    var connection2 = HubConnectionContextUtils.Create(client2.Connection);

                    await manager.OnConnectedAsync(connection1);

                    await manager.OnConnectedAsync(connection2);

                    await manager.SendConnectionsAsync(new string[] { connection1.ConnectionId, connection2.ConnectionId }, "Hello", new object[] { "World" });

                    await AssertMessageAsync(client1);
                    await AssertMessageAsync(client2);
                }
        }
        public async Task AddGroupAsync_ForLocalConnection_AlreadyInGroup_SkipsDuplicate()
        {
            var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);

            using (var client = new TestClient())
            {
                var connection = HubConnectionContextUtils.Create(client.Connection);

                await manager.OnConnectedAsync(connection);

                await manager.AddToGroupAsync(connection.ConnectionId, "dmx");

                await manager.AddToGroupAsync(connection.ConnectionId, "dmx");

                var grain  = this._fixture.ClientProvider.GetClient().GetGroupGrain("MyHub", "dmx");
                var result = await grain.Count();

                Assert.Equal(1, result);
            }
        }
        public async Task InvokeGroupAsync_OnServer_WithoutConnection_WritesOutputTo_GroupConnection()
        {
            var manager1 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);
            var manager2 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);

            using (var client = new TestClient())
            {
                var output = Channel.CreateUnbounded <HubMessage>();

                var connection = new HubConnectionContext(output, client.Connection);

                await manager1.OnConnectedAsync(connection);

                await manager1.AddGroupAsync(connection.ConnectionId, "tupac");

                await manager2.InvokeGroupAsync("tupac", "Hello", new object[] { "World" });

                AssertMessage(output);
            }
        }
        public async Task DisconnectConnection_RemovesConnection_FromGroup()
        {
            var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);

            using (var client = new TestClient())
            {
                var connection = HubConnectionContextUtils.Create(client.Connection);

                await manager.OnConnectedAsync(connection);

                await manager.AddToGroupAsync(connection.ConnectionId, "dre");

                await manager.OnDisconnectedAsync(connection);

                var grain  = this._fixture.ClientProvider.GetClient().GetGroupGrain("MyHub", "dre");
                var result = await grain.Count();

                Assert.Equal(0, result);
            }
        }
        public async Task InvokeConnectionAsync_ForLocalConnection_DoesNotPublish()
        {
            var manager1 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);
            var manager2 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);

            using (var client = new TestClient())
            {
                var connection = HubConnectionContextUtils.Create(client.Connection);

                // Add connection to both "servers" to see if connection receives message twice
                await manager1.OnConnectedAsync(connection);

                await manager2.OnConnectedAsync(connection);

                await manager1.SendConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" });

                await AssertMessageAsync(client);

                Assert.Null(client.TryRead());
            }
        }
        public async Task InvokeConnectionAsync_ForLocalConnection_DoesNotPublish()
        {
            var manager1 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);
            var manager2 = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);

            using (var client = new TestClient())
            {
                var output = Channel.CreateUnbounded <HubMessage>();

                var connection = new HubConnectionContext(output, client.Connection);

                // Add connection to both "servers" to see if connection receives message twice
                await manager1.OnConnectedAsync(connection);

                await manager2.OnConnectedAsync(connection);

                await manager1.InvokeConnectionAsync(connection.ConnectionId, "Hello", new object[] { "World" });

                AssertMessage(output);
                Assert.False(output.In.TryRead(out var item));
            }
        }
        public async Task InvokeGroupAsync_WritesTo_AllConnections_InGroup_Output()
        {
            using (var client1 = new TestClient())
                using (var client2 = new TestClient())
                {
                    var manager     = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);
                    var connection1 = HubConnectionContextUtils.Create(client1.Connection);
                    var connection2 = HubConnectionContextUtils.Create(client2.Connection);

                    await manager.OnConnectedAsync(connection1);

                    await manager.OnConnectedAsync(connection2);

                    await manager.AddToGroupAsync(connection1.ConnectionId, "gunit");

                    await manager.SendGroupAsync("gunit", "Hello", new object[] { "World" });

                    await AssertMessageAsync(client1);

                    Assert.Null(client2.TryRead());
                }
        }
        public async Task DisconnectConnection_RemovesConnection_FromGroup()
        {
            var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);

            using (var client = new TestClient())
            {
                var output = Channel.CreateUnbounded <HubMessage>();

                var connection = new HubConnectionContext(output, client.Connection);

                await manager.OnConnectedAsync(connection);

                await manager.AddGroupAsync(connection.ConnectionId, "dre");

                await manager.OnDisconnectedAsync(connection);

                var grain  = this._fixture.Client.GetGroupGrain("MyHub", "dre");
                var result = await grain.Count();

                Assert.Equal(0, result);
            }
        }
        public async Task InvokeAllAsync_DoesNotWriteTo_DisconnectedConnections_Output()
        {
            using (var client1 = new TestClient())
                using (var client2 = new TestClient())
                {
                    var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.ClientProvider);

                    var connection1 = HubConnectionContextUtils.Create(client1.Connection);
                    var connection2 = HubConnectionContextUtils.Create(client2.Connection);

                    await manager.OnConnectedAsync(connection1);

                    await manager.OnConnectedAsync(connection2);

                    await manager.OnDisconnectedAsync(connection2);

                    await manager.SendAllAsync("Hello", new object[] { "World" });

                    await AssertMessageAsync(client1);

                    Assert.Null(client2.TryRead());
                }
        }
Ejemplo n.º 26
0
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            stoppingToken.Register(async() =>
            {
                foreach (var item in clientDisposables.Values)
                {
                    item.Dispose();
                }
                foreach (var item in testClients.Values)
                {
                    item.Abort();
                }
                foreach (var item in managers.Values)
                {
                    item.Dispose();
                }
                await _testCluster.Client.Close();

                _logger.LogInformation(2, "stopped.");
            });



            Observable.FromAsync(() => Console.In.ReadLineAsync())
            .Repeat()
            .Where(value => !string.IsNullOrEmpty(value))
            .Select(value => value.Split(' '))
            .SubscribeOn(TaskPoolScheduler.Default)
            .Subscribe(async(string[] value) =>
            {
                await Task.CompletedTask;

                try
                {
                    switch (value[0])
                    {
                    case "m":
                        {
                            var managerId = value[1];

                            var groupPartitioner = new DefaultClientSetPartitioner <IGroupPartitionGrain>();
                            var userPartitioner  = new DefaultClientSetPartitioner <IUserPartitionGrain>();
                            managers[managerId]  = new OrleansHubLifetimeManager <SampleHub>(Options.Create(new OrleansOptions <SampleHub> {
                                ClusterClient = _testCluster.Client
                            }),
                                                                                             groupPartitioner,
                                                                                             userPartitioner,
                                                                                             new DefaultUserIdProvider(),
                                                                                             _loggerFactory.CreateLogger <OrleansHubLifetimeManager <SampleHub> >());

                            groupPartitioners[managerId] = groupPartitioner;
                            userPartitioners[managerId]  = userPartitioner;
                        }
                        break;

                    case "dm":
                        {
                            var managerId = value[1];

                            managers[managerId].Dispose();
                        }
                        break;

                    case "sa":
                        {
                            var managerId = value[1];

                            await managers[managerId].SendAllAsync("Hello", new object[] { "World" });
                        }
                        break;

                    case "sg":
                        {
                            var managerId = value[1];
                            var groupName = value[2];

                            await managers[managerId].SendGroupAsync(groupName, "Hello", new object[] { "World" });
                        }
                        break;

                    case "atg":
                        {
                            var managerId    = value[1];
                            var connectionId = value[2];
                            var groupName    = value[3];

                            await managers[managerId].AddToGroupAsync(testClients[connectionId].ConnectionId, groupName);
                        }
                        break;

                    case "rfg":
                        {
                            var managerId    = value[1];
                            var connectionId = value[2];
                            var groupName    = value[3];

                            await managers[managerId].RemoveFromGroupAsync(testClients[connectionId].ConnectionId, groupName);
                        }
                        break;

                    case "c":
                        {
                            var managerId    = value[1];
                            var connectionId = value[2];
                            var userId       = value[3];

                            var client = new TestClient(userIdentifier: userId);

                            var connection            = HubConnectionContextUtils.Create(client.Connection);
                            testClients[connectionId] = connection;

                            await managers[managerId].OnConnectedAsync(connection);

                            var disposable = Observable.Repeat(Observable.FromAsync(() => client.ReadAsync()))
                                             .ObserveOn(TaskPoolScheduler.Default)
                                             .Subscribe(message =>
                            {
                                var _message = message as InvocationMessage;
                                _logger.LogInformation($"Method {_message.Target}, Args {JsonConvert.SerializeObject(_message.Arguments)}");
                            });
                            clientDisposables[connectionId] = disposable;
                        }
                        break;

                    case "ga":
                        {
                            var managerId = value[1];

                            var result2 = await groupPartitioners[managerId].GetAllClientSetIdsAsync(_testCluster.Client, typeof(SampleHub).GUID);
                            var result3 = await userPartitioners[managerId].GetAllClientSetIdsAsync(_testCluster.Client, typeof(SampleHub).GUID);
                            _logger.LogInformation($"GroupNames: {JsonConvert.SerializeObject(result2)}, " +
                                                   $"UserIds: {JsonConvert.SerializeObject(result3)}");
                        }
                        break;

                    case "dc":
                        {
                            var managerId    = value[1];
                            var connectionId = value[2];

                            await managers[managerId].OnDisconnectedAsync(testClients[connectionId]);
                        }
                        break;


                    //case "sr":
                    //    {
                    //        var range = RangeFactory.CreateRange(uint.Parse(value[1]), uint.Parse(value[2]));
                    //        var subRanges = RangeFactory.GetSubRanges(range);
                    //        _logger.LogInformation($"subRanges: {JsonConvert.SerializeObject(subRanges)}");



                    //        //var id = Utils.CalculateIdHash(value[1]);
                    //        //_logger.LogInformation($"id: {id}");
                    //    }
                    //    break;
                    //case "ifr":
                    //    {
                    //        var fullRange = RangeFactory.CreateFullRange();
                    //        _logger.LogInformation($"{value[1]} in full range: {fullRange.InRange(uint.Parse(value[1]))}");
                    //    }
                    //    break;
                    //case "ir":
                    //    {
                    //        var range = RangeFactory.CreateRange(uint.Parse(value[1]), uint.Parse(value[2]));
                    //        _logger.LogInformation($"{value[3]} in range: {range.InRange(uint.Parse(value[3]))}");
                    //    }
                    //    break;
                    default:
                        break;
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "Exception onNext.");
                }
            },
                       error => _logger.LogError(error, "OnError."),
                       () => _logger.LogInformation("OnCompleted."));

            return(Task.CompletedTask);
        }
 public async Task InvokeConnectionAsync_OnNonExistentConnection_WithoutCalling_OnConnect_ThrowsException()
 {
     var manager = new OrleansHubLifetimeManager <MyHub>(new LoggerFactory().CreateLogger <OrleansHubLifetimeManager <MyHub> >(), this._fixture.Client);
     await Assert.ThrowsAsync <InvalidOperationException>(() => manager.InvokeConnectionAsync("NotARealConnectionIdV2", "Hello", new object[] { "World" }));
 }