public void SelectCharacter(DeepTalk hub, string package, UserDB user, string tcpId, IMongoCollection <UserDB> manager, DeepTalkService talkService) { var currentAccount = user.Accounts.FirstOrDefault(c => c.TcpId == tcpId); string[] splittedData = package.Substring(3).Split('|'); int count = 2; bool found = false; List <Character> characters = new List <Character>(); hub.CallCheck(tcpId).Wait(); DeepTalk.IsScans.TryGetValue(tcpId, out bool isScan); while (count < splittedData.Length && !found) { string[] _loc11_ = splittedData[count].Split(';'); int id = int.Parse(_loc11_[0]); string characterName = _loc11_[1]; byte Level = byte.Parse(_loc11_[2]); short model = short.Parse(_loc11_[3]); if (isScan) { characters.Add(new Character() { BreedId = model, Key = id, Name = characterName, Level = Level }); } if (!isScan && currentAccount != null) { if (characterName.ToLower().Equals(currentAccount.CurrentCharacter.Name.ToLower())) { hub.SendPackage($"AS{id}", tcpId, true); hub.SendPackage($"Af", tcpId); hub.DispatchToClient(new LogMessage(LogType.SYSTEM_INFORMATION, $"Selection du personnage {characterName}", tcpId), tcpId).Wait(); Debug.WriteLine("Add character " + currentAccount.CurrentCharacter.Key + " to memory"); Storage.Instance.AddCharacter(currentAccount.CurrentCharacter); found = true; } } count++; } if (isScan) { user.Accounts.FirstOrDefault(c => c.TcpId == tcpId).Characters = characters; manager.ReplaceOneAsync(c => c.Id == user.Id, user).Wait(); hub.DispatchToClient(new CharactersMessage(characters, tcpId), tcpId).Wait(); hub.DisconnectCli(tcpId, true).Wait(); } }