Beispiel #1
0
        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));
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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();
        }