async void RegisterNotifications() { await connection.Subscribe("bc", connection.AccountID()); await connection.Subscribe("cn", connection.AccountID()); await connection.Subscribe("gn", connection.AccountID()); }
private void connection_OnLogin(object sender, string username, string ipAddress) { new Thread((ThreadStart)(async() => { updateStatus("Connecting...", Accountname); loginPacket = await connection.GetLoginDataPacketForUser(); if (loginPacket.AllSummonerData == null) { Random rnd = new Random(); String summonerName = Accountname; if (summonerName.Length > 16) { summonerName = summonerName.Substring(0, 11) + new Random().Next(1000, 9999).ToString(); } updateStatus("Create Summoner: " + summonerName, Accountname); await connection.CreateDefaultSummoner(summonerName); } await connection.Subscribe("bc", loginPacket.AllSummonerData.Summoner.AcctId); await connection.Subscribe("cn", loginPacket.AllSummonerData.Summoner.AcctId); await connection.Subscribe("gn", loginPacket.AllSummonerData.Summoner.AcctId); sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level; sumName = loginPacket.AllSummonerData.Summoner.Name; sumId = loginPacket.AllSummonerData.Summoner.SumId; rpBalance = loginPacket.RpBalance; if (sumLevel > parent.maxLevel || sumLevel == parent.maxLevel) { connection.Disconnect(); updateStatus("Summoner: " + sumName + " is already max level.", Accountname); updateStatus("Log into new account.", Accountname); parent.lognNewAccount(); return; } if (sumLevel < 3.0 && queueType == QueueTypes.NORMAL_5x5) { this.updateStatus("Need to be Level 3 before NORMAL_5x5 queue.", Accountname); this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 3", Accountname); queueType = QueueTypes.BEGINNER_BOT; actualQueueType = QueueTypes.NORMAL_5x5; } else if (sumLevel < 6.0 && queueType == QueueTypes.ARAM) { this.updateStatus("Need to be Level 6 before ARAM queue.", Accountname); this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 6", Accountname); queueType = QueueTypes.BEGINNER_BOT; actualQueueType = QueueTypes.ARAM; } else if (sumLevel < 7.0 && queueType == QueueTypes.NORMAL_3x3) { this.updateStatus("Need to be Level 7 before NORMAL_3x3 queue.", Accountname); this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 7", Accountname); queueType = QueueTypes.BEGINNER_BOT; actualQueueType = QueueTypes.NORMAL_3x3; } if ((loginPacket.AllSummonerData.Summoner.ProfileIconId == -1 || loginPacket.AllSummonerData.Summoner.ProfileIconId == 1)) { double[] ids = new double[Convert.ToInt32(sumId)]; string icons = await connection.GetSummonerIcons(ids); List <int> availableIcons = new List <int> { }; var random = new Random(); for (int i = 0; i < 29; i++) { availableIcons.Add(i); } foreach (var id in icons) { availableIcons.Add(Convert.ToInt32(id)); } int index = random.Next(availableIcons.Count); int randomIcon = availableIcons[index]; await connection.UpdateProfileIconId(randomIcon); } if (rpBalance == 400.0 && parent.buyBoost && sumLevel < 5) { updateStatus("Buying XP Boost", Accountname); try { Task t = new Task(buyBoost); t.Start(); } catch (Exception exception) { updateStatus("Couldn't buy RP Boost.\n" + exception, Accountname); } } updateStatus("Logged in as " + loginPacket.AllSummonerData.Summoner.Name + " @ level " + loginPacket.AllSummonerData.SummonerLevel.Level, Accountname); availableChampsArray = await connection.GetAvailableChampions(); PlayerDTO player = await connection.CreatePlayer(); if (loginPacket.ReconnectInfo != null && loginPacket.ReconnectInfo.Game != null) { connection_OnMessageReceived(sender, (object)loginPacket.ReconnectInfo.PlayerCredentials); } else { connection_OnMessageReceived(sender, (object)new EndOfGameStats()); } })).Start(); }
private void connection_OnLogin(object sender, string username, string ipAddress) { new Thread(async() => { App.gameMask.findAndKillHflWindow(info.username, info.region.ToString()); loginDataPacket = await connection.GetLoginDataPacketForUser(); #region createSummoner if (loginDataPacket.AllSummonerData == null) { Random random = new Random(); string summonerName = info.username; if (summonerName.Length > 16) { summonerName = summonerName.Substring(0, 12) + new Random().Next(1000, 9999).ToString(); } await connection.CreateDefaultSummoner(summonerName); updateStatus(msgStatus.INFO, "Created Summoner: " + summonerName); } #endregion loginDataPacket = await connection.GetLoginDataPacketForUser(); #region registerMessages await connection.Subscribe("bc", loginDataPacket.AllSummonerData.Summoner.AcctId); await connection.Subscribe("cn", loginDataPacket.AllSummonerData.Summoner.AcctId); await connection.Subscribe("gn", loginDataPacket.AllSummonerData.Summoner.AcctId); #endregion #region ackDialogBusterWarning await connection.ackLeaverBusterWarning(); await connection.callPersistenceMessaging(new SimpleDialogMessageResponse() { AccountID = loginDataPacket.AllSummonerData.Summoner.SumId, MsgID = loginDataPacket.AllSummonerData.Summoner.SumId, Command = "ack" }); #endregion #region fetchSummonerData info.summonerId = loginDataPacket.AllSummonerData.Summoner.SumId; info.currentLevel = loginDataPacket.AllSummonerData.SummonerLevel.Level; info.currentIp = loginDataPacket.IpBalance; info.expToNextLevel = loginDataPacket.AllSummonerData.SummonerLevel.ExpToNextLevel;; info.currentXp = loginDataPacket.AllSummonerData.SummonerLevelAndPoints.ExpPoints; info.currentRp = loginDataPacket.RpBalance; info.summonerName = loginDataPacket.AllSummonerData.Summoner.Name; myChampions = await connection.GetAvailableChampions(); await connection.CreatePlayer(); sessionManager.smurfStart(info.username, info.region, info.currentXp, info.currentIp, info.currentLevel, info.expToNextLevel); updateStatus(msgStatus.INFO, "Logged in as " + info.summonerName + " @ level " + info.currentLevel); #endregion #region checkReconnectState if (loginDataPacket.ReconnectInfo != null && loginDataPacket.ReconnectInfo.Game != null) { connection_OnMessageReceived(sender, loginDataPacket.ReconnectInfo.PlayerCredentials); return; } #endregion #region startSoloSequence if (type == RotationType.SmurfDone) { if (info.desiredLevel <= loginDataPacket.AllSummonerData.SummonerLevel.Level) { connection.Disconnect(); return; } } object obj4 = await connection.ackLeaverBusterWarning(); object obj5 = await connection.callPersistenceMessaging(new SimpleDialogMessageResponse() { AccountID = loginDataPacket.AllSummonerData.Summoner.SumId, MsgID = loginDataPacket.AllSummonerData.Summoner.SumId, Command = "ack" }); MatchMakerParams matchParams = new MatchMakerParams(); checkAndUpdateQueueType(); if (QueueType == QueueTypes.INTRO_BOT) { matchParams.BotDifficulty = "INTRO"; } else if (QueueType == QueueTypes.BEGINNER_BOT) { matchParams.BotDifficulty = "EASY"; } else if (QueueType == QueueTypes.MEDIUM_BOT) { matchParams.BotDifficulty = "MEDIUM"; } updateStatus(msgStatus.INFO, QueueType.ToString()); if (QueueType != 0) { matchParams.QueueIds = new int[1] { (int)QueueType }; SearchingForMatchNotification m = await connection.AttachToQueue(matchParams); if (m.PlayerJoinFailures == null) { updateStatus(msgStatus.INFO, "In Queue: " + QueueType.ToString()); } else { foreach (var failure in m.PlayerJoinFailures) { if (failure.ReasonFailed == "LEAVER_BUSTED") { m_accessToken = failure.AccessToken; if (failure.LeaverPenaltyMillisRemaining > m_leaverBustedPenalty) { m_leaverBustedPenalty = failure.LeaverPenaltyMillisRemaining; } } } if (String.IsNullOrEmpty(m_accessToken)) { foreach (var failure in m.PlayerJoinFailures) { updateStatus(msgStatus.INFO, "Dodge Remaining Time: " + Convert.ToString((failure.DodgePenaltyRemainingTime / 1000 / (float)60)).Replace(",", ":") + "..."); } } else { double minutes = m_leaverBustedPenalty / 1000 / (float)60; updateStatus(msgStatus.INFO, "Waiting out leaver buster: " + minutes + " minutes!"); t = TimeSpan.FromMinutes((int)minutes); //Tick(); ->Visual Timer Thread.Sleep(TimeSpan.FromMilliseconds(m_leaverBustedPenalty)); m = await connection.AttachToLowPriorityQueue(matchParams, m_accessToken); if (m.PlayerJoinFailures == null) { updateStatus(msgStatus.INFO, "Succesfully joined lower priority queue!"); } else { updateStatus(msgStatus.ERROR, "There was an error in joining lower priority queue.\nDisconnecting."); connection.Disconnect(); } } } } #endregion }).Start(); }