private async void AddToGroup(string groupId, User user) { if (user.GroupId != default && groupId != user.GroupId) { ActiveGroups.RemoveUserFromGroup(user.GroupId, user); } if (groupId != user.GroupId) { ActiveGroups.AddUserToGroup(groupId, user); } await Groups.AddToGroupAsync(user.ConnectionId, groupId); }
public void PurgeUsers() { this.purgeUsersTimer = new Timer((e) => { User[] users = ConnectedUsers.Users.Where(x => x.Disconnected && x.ExpirationTime < DateTime.Now).ToArray(); foreach (User user in users) { ActiveGroups.RemoveUserFromGroup(user.GroupId, user); } ConnectedUsers.Users.Where(x => x.Disconnected && x.ExpirationTime < DateTime.Now).ToArray(); }, null, 0, 60000); }