예제 #1
0
        public override void OnDisconnect(WZClient session)
        {
            var Session = session as GSSession;

            if (Session.Player != null)
            {
                if (Session.Player.Character != null)
                {
                    Program.client
                    .SendAsync(new SCRem
                    {
                        Server = (byte)Program.ServerCode,
                        List   = new CliRemDto[] {
                            new CliRemDto {
                                btName = Session.Player.Character.Name.GetBytes()
                            }
                        }
                    });

                    PartyManager.CancelMatching(Session.Player);
                }
                Session.Player.Status = LoginStatus.NotLogged;

                using (var db = new GameContext())
                {
                    if (Session.Player.Account != null)
                    {
                        var acc = (from a in db.Accounts
                                   where a.AccountId == Session.Player.Account.ID
                                   select a).First();

                        acc.IsConnected = false;

                        db.Accounts.Update(acc);
                        db.SaveChanges();
                        Logger.ForAccount(Session).Information("Disconnecting...");
                    }
                }
                Session.Player.Account = null;
            }
            //db.SaveChanges();

            Session.Player = null;
            base.OnDisconnect(session);
            Disconnect?.Invoke(this, new WZServerEventArgs {
                session = Session
            });
        }