/// <summary> /// The method called when using the 'close chat' button. This is then used to inform the other /// group members that the user has left the chat. /// </summary> /// <param name="chat">Chat with members</param> /// <returns></returns> public async Task LeaveGroup(Chat chat) { var connectionId = Context.ConnectionId; var leavingUser = _users.Get(connectionId); // TODO use OthersInGroup method to simplify frontend await Clients.Group(chat.Id).SendAsync("leaveGroup", chat, leavingUser); foreach (var user in chat.Users) { await Groups.RemoveFromGroupAsync(user.ConnectionId, chat.Id); } }