public async Task <IActionResult> IdentifyAsync(string subscriberId, [FromBody] User user) { user.Guid = (await _connections.GetConnectionInfoAsync(subscriberId)).Guid; await _broadcastService.IdentifyAsync(subscriberId, user); return(Ok()); }
public async Task SubscribeAsync(string subscriberId, string channel) { await _subscriptions.SubscribeAsync(subscriberId, channel); await _context.Groups.AddToGroupAsync(subscriberId, channel); var user = await _connections.GetConnectionInfoAsync(subscriberId); await PublishAsync(channel, new Subscribe { Channel = channel, User = user }); await Task.WhenAll((await _subscriptions.GetSubscribersAsync(channel)).Select(async subscriber => { if (subscriber != subscriberId) { user = await _connections.GetConnectionInfoAsync(subscriber); await WhisperAsync(subscriberId, new Subscribe { Channel = channel, User = user }); } })); }