예제 #1
0
        public override Task SendConnectionsAsync(IReadOnlyList <string> connectionIds, string methodName, object[] args)
        {
            if (connectionIds == null)
            {
                throw new ArgumentNullException(nameof(connectionIds));
            }
            var publishTasks = new List <Task>(connectionIds.Count);
            var message      = new RedisInvocationMessage(target: methodName, arguments: args);

            foreach (string connectionId in connectionIds)
            {
                var connection = _connections[connectionId];
                // If the connection is local we can skip sending the message through the bus since we require sticky connections.
                // This also saves serializing and deserializing the message!
                if (connection != null)
                {
                    publishTasks.Add(connection.WriteAsync(message.CreateInvocation()));
                }
                else
                {
                    publishTasks.Add(PublishAsync(_channelNamePrefix + "." + connectionId, message));
                }
            }

            return(Task.WhenAll(publishTasks));
        }
예제 #2
0
        public override Task SendConnectionAsync(string connectionId, string methodName, object[] args)
        {
            if (connectionId == null)
            {
                throw new ArgumentNullException(nameof(connectionId));
            }

            var message = new RedisInvocationMessage(target: methodName, arguments: args);

            // If the connection is local we can skip sending the message through the bus since we require sticky connections.
            // This also saves serializing and deserializing the message!
            var connection = _connections[connectionId];

            if (connection != null)
            {
                return(connection.WriteAsync(message.CreateInvocation()));
            }

            return(PublishAsync(_channelNamePrefix + "." + connectionId, message));
        }