private Task SubscribeToGroupAsync(string groupChannel, HubConnectionStore groupConnections)
        {
            RedisLog.Subscribing(_logger, groupChannel);
            var server = _options.ServerResovler.Resolve(_shardingServers, groupChannel);

            return(server.Subscriber.SubscribeAsync(groupChannel, async(_, data) =>
            {
                try
                {
                    var invocation = _protocol.ReadInvocation((byte[])data);
                    var tasks = groupConnections.AsEnumerable()
                                .Where(connection =>
                    {
                        if (invocation.ExcludedConnectionIds == null)
                        {
                            return true;
                        }

                        return !invocation.ExcludedConnectionIds.Contains(connection.ConnectionId);
                    })
                                .Select(connection =>
                    {
                        var task = connection.WriteAsync(invocation.Message);
                        return task.AsTask();
                    });

                    await Task.WhenAll(tasks);
                }
                catch (Exception ex)
                {
                    RedisLog.FailedWritingMessage(_logger, ex);
                }
            }));
        }
        private void SubscribeToAll(IRedisServer server)
        {
            if (!server.IsDedicatedForAllChannel)
            {
                return;
            }

            RedisLog.Subscribing(_logger, _channels.All);
            server.Subscriber.Subscribe(_channels.All, async(_, data) =>
            {
                try
                {
                    RedisLog.ReceivedFromChannel(_logger, _channels.All);
                    var invocation = _protocol.ReadInvocation((byte[])data);
                    var tasks      = _connections.AsEnumerable()
                                     .Where(connectionContext =>
                    {
                        if (invocation.ExcludedConnectionIds == null)
                        {
                            return(true);
                        }

                        return(!invocation.ExcludedConnectionIds.Contains(connectionContext.ConnectionId));
                    })
                                     .Select(connectionContext => connectionContext.WriteAsync(invocation.Message).AsTask());

                    await Task.WhenAll(tasks);
                }
                catch (Exception ex)
                {
                    RedisLog.FailedWritingMessage(_logger, ex);
                }
            });
        }