Example #1
0
        protected void Kick(string[] args)
        {
            Character character;

            if (Tasks.LifeCycle.TryGetByName(args[2], out character))
            {
                SMSG_KICKSESSION spkt = new SMSG_KICKSESSION();
                spkt.SessionId = character.id;
                character.client.Send((byte[])spkt);
            }
        }
Example #2
0
        private void Client_OnClose(object sender, EventArgs e)
        {
            try
            {
                CM_PARTYQUIT(null);

                //Release current session
                Singleton.NetworkService.AuthenticationClient.SM_RELEASESESSION(this.character.id);

                if (this.IsConnected == true)
                {
                    SMSG_KICKSESSION spkt2 = new SMSG_KICKSESSION();
                    spkt2.SessionId = this.character.id;
                    this.Send((byte[])spkt2);
                }
            }
            catch (Exception) { }

            try
            {
                if (this.character != null)
                {
                    GC.SuppressFinalize(this.character);                    //Disallows garbage collector to clean up

                    if (this.character.currentzone != null)                 //Leave the current zone if any
                    {
                        this.character.currentzone.OnLeave(this.character); //zone you are registered on.
                    }
                    LifeCycle.Unsubscribe(this.character);                  //Unsubscribe yourself on life thread
                    //Singleton.Database.SaveCharacter(this.character);

                    if (Singleton.Database.TransSave(this.character) == false)
                    {
                        Trace.WriteLine("Creating restore point could not save into database");
                        Singleton.Database.CreateRestorePoint(this.character);
                    }
                    if (this.character != null)
                    {
                        GC.ReRegisterForFinalize(this.character);               //Allow garbage collector to clean up
                    }
                }

                //Set character instance to null
                this.character = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
 protected void Kick(string[] args)
 {
     Character character;
     if (Tasks.LifeCycle.TryGetByName(args[2], out character))
     {
         SMSG_KICKSESSION spkt = new SMSG_KICKSESSION();
         spkt.SessionId = character.id;
         character.client.Send((byte[])spkt);
     }
 }
Example #4
0
        private void Client_OnClose(object sender, EventArgs e)
        {
            try
            {
                CM_PARTYQUIT(null);

                //Release current session
                Singleton.NetworkService.AuthenticationClient.SM_RELEASESESSION(this.character.id);

                if (this.IsConnected == true)
                {
                    SMSG_KICKSESSION spkt2 = new SMSG_KICKSESSION();
                    spkt2.SessionId = this.character.id;
                    this.Send((byte[])spkt2);
                }
            }
            catch (Exception) { }

            try
            {
                if (this.character != null)
                {
                    GC.SuppressFinalize(this.character);                    //Disallows garbage collector to clean up

                    if (this.character.currentzone != null)                //Leave the current zone if any
                        this.character.currentzone.OnLeave(this.character);     //zone you are registered on.

                    LifeCycle.Unsubscribe(this.character);                  //Unsubscribe yourself on life thread
                    //Singleton.Database.SaveCharacter(this.character);

                    if (Singleton.Database.TransSave(this.character) == false)
                    {
                        Trace.WriteLine("Creating restore point could not save into database");
                        Singleton.Database.CreateRestorePoint(this.character);
                    }

                    GC.ReRegisterForFinalize(this.character);               //Allow garbage collector to clean up
                }

                //Set character instance to null
                this.character = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }