示例#1
0
        private async void LogoutTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            // First, remove player from game world.
            // Because some managers like Guild Manager provide GuildId and player can be found in guild map ONLY if this id is presented.
            _gameWorld.RemovePlayer(CharId);

            try
            {
                // ONLY after player is unloaded from game world we can clear session servises.
                await Client.ClearSession(_quitGame);
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed clear session for {characterId}. Reason: {message}. Stack trace: {trace}", CharId, ex.Message, ex.StackTrace);
            }

            CharId       = 0;
            IsLoggingOff = false;

            if (_quitGame)
            {
                _packetFactory.SendQuitGame(Client);
            }
            else
            {
                _packetFactory.SendLogout(Client);
                Client.CryptoManager.UseExpandedKey = false;

                _packetFactory.SendCharacterList(Client, await _selectionScreenManager.GetCharacters(Client.UserId));
                _packetFactory.SendFaction(Client, await _selectionScreenManager.GetFaction(Client.UserId), await _selectionScreenManager.GetMaxMode(Client.UserId));
            }
        }
示例#2
0
        /// <inheritdoc />
        protected override void OnClientDisconnected(WorldClient client)
        {
            base.OnClientDisconnected(client);

            SelectionScreenManagers.Remove(client.Id, out var manager);
            manager.Dispose();
            client.OnPacketArrived -= Client_OnPacketArrived;

            _gameWorld.RemovePlayer(client.CharID);
        }