public async Task StartAuth(string token) { var user = await _socket.GetUserByAccessToken(token); if (user == null) { // Send User the info that he isnt allowed Context.Abort(); return; } var foundEntry = MyUsers.AddOrUpdate(user.Id, new List <string> { Context.ConnectionId }, (key, value) => { value.Add(Context.ConnectionId); return(value); }); var groupChats = await _groupChat.GetByUserAsync(user); foreach (var groupChat in groupChats) { await Groups.AddToGroupAsync(Context.ConnectionId, "groupchat#" + groupChat.Id); } }
private async Task <bool> AuthenticateAsync(WebSocket ws) { var handshake = await ReceiveAsyc <HandshakeInput>(ws); if (_socket.GetUserByAccessToken(handshake.Token) == null) { return(false); } return(true); }