예제 #1
0
        private async void InitGameSession(SessionResponse sessionInfo)
        {
            _interClient.OnSessionResponse -= InitGameSession;

            var worldClient = _server.ConnectedUsers.First(x => x.Id == _sessionId);

            worldClient.CryptoManager.GenerateAES(sessionInfo.KeyPair.Key, sessionInfo.KeyPair.IV);

            _gameSession.Client = worldClient;

            _packetFactory.SendGameHandshake(worldClient);

            _packetFactory.SendCharacterList(worldClient, await _selectionScreenManager.GetCharacters(worldClient.UserId));
            _packetFactory.SendFaction(worldClient, await _selectionScreenManager.GetFaction(worldClient.UserId), await _selectionScreenManager.GetMaxMode(worldClient.UserId));
        }
예제 #2
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));
            }
        }