private static void OnLogout(LogoutEventArgs e) { if (e == null || !(e.Mobile is PlayerMobile)) { return; } var user = (PlayerMobile)e.Mobile; AllChannels.Where(c => c.IsUser(user)).ForEach(c => c.Leave(user)); }
private static void OnLogin(LoginEventArgs e) { if (e == null || !(e.Mobile is PlayerMobile)) { return; } var user = (PlayerMobile)e.Mobile; AllChannels.Where(c => user.AccessLevel <= c.Access && c.Available && c.AutoJoin).ForEach(c => c.Join(user)); }
public async Task UpdateChannel(string oldName, Channel channel) { if (oldName != channel.Name) { Channel[] channelsWithNewName = AllChannels.Where(otherChannel => otherChannel.Name == channel.Name) .ToArray(); if (channelsWithNewName.Length == 0) { channel.Discriminator = 0; } else { channel.Discriminator = (ushort)(channelsWithNewName.Max(otherChannel => otherChannel.Discriminator) + 1); } } _appDbContext.Channels.Update(channel); await _appDbContext.SaveChangesAsync(); }