private void WriteConnection(RabbitMQInvocation invocation, string connectionId) { if (this._Connections.TryGetValue(connectionId, out HubConnectionContext hubConnection)) { Write(hubConnection, invocation); } }
private void WriteGroup(RabbitMQInvocation invocation, string groupId) { if (this._Groups.TryGetValue(groupId, out HubConnectionStore groupStroe)) { Write(groupStroe.GetEnumerator(), invocation, groupStroe.Count); } }
private void WriteUser(RabbitMQInvocation invocation, string userId) { if (this._Users.TryGetValue(userId, out HubConnectionContext connection)) { Write(connection, invocation); } }
private void WriteConnection(string connectionId, RabbitMQInvocation invocation) { if (this._Connections.TryGetValue(connectionId, out HubConnectionContext hubConnection)) { hubConnection.WriteAsync(invocation.Message).AsTask().Wait(); } }
private void Write(IEnumerator <HubConnectionContext> connections, RabbitMQInvocation invocation, int count = 1) { var tasks = new List <Task>(count); while (connections.MoveNext()) { if (invocation.ExcludedConnectionIds == null || !invocation.ExcludedConnectionIds.Contains(connections.Current.ConnectionId)) { tasks.Add(connections.Current.WriteAsync(invocation.Message).AsTask()); } } Task.WaitAll(tasks.ToArray()); }
private void WriteUser(string userId, RabbitMQInvocation invocation) { List <Task> tasks = new List <Task>(); if (this._Users.TryGetValue(userId, out HubConnectionStore store)) { var connections = store.GetEnumerator(); while (connections.MoveNext()) { tasks.Add(connections.Current.WriteAsync(invocation.Message).AsTask()); } } Task.WaitAll(tasks.ToArray()); }
private void WriteUsers(IReadOnlyList <string> users, RabbitMQInvocation invocation) { var tasks = new List <Task>(users.Count); foreach (var userId in users) { if (this._Users.TryGetValue(userId, out HubConnectionStore store)) { var connections = store.GetEnumerator(); while (connections.MoveNext()) { tasks.Add(connections.Current.WriteAsync(invocation.Message).AsTask()); } } } Task.WaitAll(tasks.ToArray()); }
private void WriteGroups(IReadOnlyList <string> groups, RabbitMQInvocation invocation) { List <Task> tasks = new List <Task>(); foreach (var groupId in groups) { if (this._Groups.TryGetValue(groupId, out HubConnectionStore groupStroe)) { var connections = groupStroe.GetEnumerator(); while (connections.MoveNext()) { if (invocation.ExcludedConnectionIds == null || !invocation.ExcludedConnectionIds.Contains(connections.Current.ConnectionId)) { tasks.Add(connections.Current.WriteAsync(invocation.Message).AsTask()); } } } } Task.WaitAll(tasks.ToArray()); }
private void Write(HubConnectionContext connection, RabbitMQInvocation invocation) { connection.WriteAsync(invocation.Message); }