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)); }
public override Task SendGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList <string> excludedIds) { if (groupName == null) { throw new ArgumentNullException(nameof(groupName)); } var message = new RedisInvocationMessage(methodName, excludedIds, args); return(PublishAsync(_channelNamePrefix + ".group." + groupName, message)); }
public override Task InvokeGroupAsync(string groupName, string methodName, object[] args) { if (groupName == null) { throw new ArgumentNullException(nameof(groupName)); } var message = new RedisInvocationMessage(target: methodName, excludedIds: null, arguments: args); return(PublishAsync(_channelNamePrefix + ".group." + groupName, message)); }
public override Task SendUsersAsync(IReadOnlyList <string> userIds, string methodName, object[] args) { if (userIds.Count > 0) { var message = new RedisInvocationMessage(methodName, args); var publishTasks = new List <Task>(userIds.Count); foreach (var userId in userIds) { if (!string.IsNullOrEmpty(userId)) { publishTasks.Add(PublishAsync(_channelNamePrefix + ".user." + userId, message)); } } return(Task.WhenAll(publishTasks)); } return(Task.CompletedTask); }
public override Task SendGroupsAsync(IReadOnlyList <string> groupNames, string methodName, object[] args) { if (groupNames == null) { throw new ArgumentNullException(nameof(groupNames)); } var publishTasks = new List <Task>(groupNames.Count); var message = new RedisInvocationMessage(target: methodName, arguments: args); foreach (var groupName in groupNames) { if (!string.IsNullOrEmpty(groupName)) { publishTasks.Add(PublishAsync(_channelNamePrefix + "." + groupName, message)); } } return(Task.WhenAll(publishTasks)); }
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)); }
public override Task SendUserAsync(string userId, string methodName, object[] args) { var message = new RedisInvocationMessage(methodName, args); return(PublishAsync(_channelNamePrefix + ".user." + userId, message)); }
public override Task SendAllExceptAsync(string methodName, object[] args, IReadOnlyList <string> excludedIds) { var message = new RedisInvocationMessage(target: methodName, excludedIds: excludedIds, arguments: args); return(PublishAsync(_channelNamePrefix + ".AllExcept", message)); }
public override Task SendAllAsync(string methodName, object[] args) { var message = new RedisInvocationMessage(target: methodName, arguments: args); return(PublishAsync(_channelNamePrefix, message)); }