public Task SendToGroup(string groupName, SignalRData data) { if (string.IsNullOrEmpty(groupName)) { throw new ArgumentException($"{nameof(groupName)} cannot be null or empty"); } return(InvokeAsync(data.Endpoints, hubContext => hubContext.Clients.Group(groupName).SendCoreAsync(data.Target, data.Arguments))); }
public Task SendToUser(string userId, SignalRData data) { if (string.IsNullOrEmpty(userId)) { throw new ArgumentException($"{nameof(userId)} cannot be null or empty"); } return(InvokeAsync(data.Endpoints, hubContext => hubContext.Clients.User(userId).SendCoreAsync(data.Target, data.Arguments))); }
public async Task SendToGroup(string hubName, string groupName, SignalRData data) { if (string.IsNullOrEmpty(groupName)) { throw new ArgumentException($"{nameof(groupName)} cannot be null or empty"); } var serviceHubContext = await serviceHubContextStore.GetOrAddAsync(hubName); await serviceHubContext.Clients.Group(groupName).SendCoreAsync(data.Target, data.Arguments); }
public async Task SendToUser(string userId, SignalRData data) { if (string.IsNullOrEmpty(userId)) { throw new ArgumentException($"{nameof(userId)} cannot be null or empty"); } var serviceHubContext = await serviceManagerStore.GetOrAddByConnectionString(connectionString).GetAsync(HubName); await serviceHubContext.Clients.User(userId).SendCoreAsync(data.Target, data.Arguments); }
public Task SendToGroup(string hubName, string groupName, SignalRData data) { if (string.IsNullOrEmpty(groupName)) { throw new ArgumentException($"{nameof(groupName)} cannot be null or empty"); } var groupSegment = $"/groups/{groupName}"; var connectionInfo = GetServerConnectionInfo(hubName, groupSegment); return(RequestAsync(connectionInfo.Url, data, connectionInfo.AccessToken, HttpMethod.Post)); }
public Task SendToUser(string hubName, string userId, SignalRData data) { if (string.IsNullOrEmpty(userId)) { throw new ArgumentException($"{nameof(userId)} cannot be null or empty"); } var userIdsSegment = $"/users/{userId}"; var connectionInfo = GetServerConnectionInfo(hubName, userIdsSegment); return(RequestAsync(connectionInfo.Url, data, connectionInfo.AccessToken, HttpMethod.Post)); }
public async Task AddAsync(T item, CancellationToken cancellationToken = default(CancellationToken)) { if (item == null) { throw new ArgumentNullException("Binding Object"); } var convertItem = converter.ConvertToSignalROutput(item); if (convertItem.GetType() == typeof(SignalRMessage)) { SignalRMessage message = convertItem as SignalRMessage; var data = new SignalRData { Target = message.Target, Arguments = message.Arguments }; if (!string.IsNullOrEmpty(message.UserId) && !string.IsNullOrEmpty(message.GroupName)) { throw new ArgumentException("GroupName and UserId can not be specified at the same time."); } if (!string.IsNullOrEmpty(message.UserId)) { await client.SendToUser(hubName, message.UserId, data).ConfigureAwait(false); } else if (!string.IsNullOrEmpty(message.GroupName)) { await client.SendToGroup(hubName, message.GroupName, data).ConfigureAwait(false); } else { await client.SendToAll(hubName, data).ConfigureAwait(false); } } else if (convertItem.GetType() == typeof(SignalRGroupAction)) { SignalRGroupAction groupAction = convertItem as SignalRGroupAction; if (groupAction.Action == GroupAction.Add) { await client.AddUserToGroup(hubName, groupAction.UserId, groupAction.GroupName).ConfigureAwait(false); } else { await client.RemoveUserFromGroup(hubName, groupAction.UserId, groupAction.GroupName).ConfigureAwait(false); } } else { throw new ArgumentException("Unsupport Binding Type."); } }
public Task SendToConnection(string connectionId, SignalRData data) { return(InvokeAsync(data.Endpoints, hubContext => hubContext.Clients.Client(connectionId).SendCoreAsync(data.Target, data.Arguments))); }
public Task SendToAll(SignalRData data) { return(InvokeAsync(data.Endpoints, hubContext => hubContext.Clients.All.SendCoreAsync(data.Target, data.Arguments))); }
public async Task SendToConnection(string connectionId, SignalRData data) { var serviceHubContext = await serviceManagerStore.GetOrAddByConnectionString(connectionString).GetAsync(HubName); await serviceHubContext.Clients.Client(connectionId).SendCoreAsync(data.Target, data.Arguments); }
public async Task AddAsync(T item, CancellationToken cancellationToken = default(CancellationToken)) { if (item == null) { throw new ArgumentNullException("Binding Object"); } var convertItem = converter.ConvertToSignalROutput(item); if (convertItem.GetType() == typeof(SignalRMessage)) { SignalRMessage message = convertItem as SignalRMessage; var data = new SignalRData { Target = message.Target, Arguments = message.Arguments }; if (!string.IsNullOrEmpty(message.ConnectionId)) { await client.SendToConnection(message.ConnectionId, data).ConfigureAwait(false); } else if (!string.IsNullOrEmpty(message.UserId)) { await client.SendToUser(message.UserId, data).ConfigureAwait(false); } else if (!string.IsNullOrEmpty(message.GroupName)) { await client.SendToGroup(message.GroupName, data).ConfigureAwait(false); } else { await client.SendToAll(data).ConfigureAwait(false); } } else if (convertItem.GetType() == typeof(SignalRGroupAction)) { SignalRGroupAction groupAction = convertItem as SignalRGroupAction; if (!string.IsNullOrEmpty(groupAction.ConnectionId)) { switch (groupAction.Action) { case GroupAction.Add: await client.AddConnectionToGroup(groupAction.ConnectionId, groupAction.GroupName).ConfigureAwait(false); break; case GroupAction.Remove: await client.RemoveConnectionFromGroup(groupAction.ConnectionId, groupAction.GroupName).ConfigureAwait(false); break; } } else if (!string.IsNullOrEmpty(groupAction.UserId)) { switch (groupAction.Action) { case GroupAction.Add: await client.AddUserToGroup(groupAction.UserId, groupAction.GroupName).ConfigureAwait(false); break; case GroupAction.Remove: await client.RemoveUserFromGroup(groupAction.UserId, groupAction.GroupName).ConfigureAwait(false); break; case GroupAction.RemoveAll: await client.RemoveUserFromAllGroups(groupAction.UserId).ConfigureAwait(false); break; } } else { throw new ArgumentException($"ConnectionId and UserId cannot be null or empty together"); } } else { throw new ArgumentException("Unsupport Binding Type."); } }
public Task SendToAll(string hubName, SignalRData data) { var connectionInfo = GetServerConnectionInfo(hubName); return(RequestAsync(connectionInfo.Url, data, connectionInfo.AccessToken, HttpMethod.Post)); }
public async Task SendToAll(string hubName, SignalRData data) { var serviceHubContext = await serviceHubContextStore.GetOrAddAsync(hubName); await serviceHubContext.Clients.All.SendCoreAsync(data.Target, data.Arguments); }