public async void connection_OnMessageReceived(object sender, object message) { if (message.ToString().Contains("LobbyStatus")) { String metaData = (String)((TypedObject)message)["gameMetaData"]; Match match = Regex.Match(metaData, "gameId\":([0-9]+),"); if (match.Success) { string gameId = match.Groups[1].Value; await connection.SwitchTeams(Convert.ToDouble(gameId)); } } else if (message is LoLLauncher.RiotObjects.Platform.Game.GameDTO) { LoLLauncher.RiotObjects.Platform.Game.GameDTO game = message as LoLLauncher.RiotObjects.Platform.Game.GameDTO; switch (game.GameState) { case "IDLE": break; case "TEAM_SELECT": if (firstTimeInCustom) { updateStatus("Entering champion selection"); await connection.StartChampionSelection(game.Id, game.OptimisticLock); firstTimeInCustom = false; } break; case "CHAMP_SELECT": firstTimeInCustom = true; firstTimeInQueuePop = true; if (firstTimeInLobby) { firstTimeInLobby = false; updateStatus("Champion Select - Waiting for game to start"); await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT"); if (queueType != QueueTypes.ARAM) { await connection.SelectChampion(availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId); await connection.ChampionSelectCompleted(); } } break; case "POST_CHAMP_SELECT": break; case "PRE_CHAMP_SELECT": break; case "START_REQUESTED": break; case "GAME_START_CLIENT": break; case "GameClientConnectedToServer": break; case "IN_PROGRESS": break; case "IN_QUEUE": break; case "POST_GAME": break; case "TERMINATED": if (queueType == QueueTypes.CUSTOM) { CreatePracticeGame(); } else { updateStatus("Re-entering queue due to someone dodging"); firstTimeInQueuePop = true; } break; case "TERMINATED_IN_ERROR": break; case "CHAMP_SELECT_CLIENT": break; case "GameReconnect": break; case "GAME_IN_PROGRESS": break; case "JOINING_CHAMP_SELECT": if (firstTimeInQueuePop) { updateStatus("Queue popped"); if (game.StatusOfParticipants.Contains("1")) { updateStatus("Accepted Queue"); firstTimeInQueuePop = false; firstTimeInLobby = true; await connection.AcceptPoppedGame(true); } } break; case "WAITING": break; case "DISCONNECTED": break; default: break; } } else if (message is LoLLauncher.RiotObjects.Platform.Game.PlayerCredentialsDto) { LoLLauncher.RiotObjects.Platform.Game.PlayerCredentialsDto credentials = message as LoLLauncher.RiotObjects.Platform.Game.PlayerCredentialsDto; System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.CreateNoWindow = false; startInfo.WorkingDirectory = installPath; startInfo.FileName = "League of Legends.exe"; startInfo.Arguments = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + credentials.ServerIp + " " + credentials.ServerPort + " " + credentials.EncryptionKey + " " + credentials.SummonerId + "\""; updateStatus("Playing League of Legends"); new Thread(() => { exeProcess = System.Diagnostics.Process.Start(startInfo); while (exeProcess.MainWindowHandle == IntPtr.Zero) { } Thread.Sleep(1000); SetParent(exeProcess.MainWindowHandle, panelHandle); MoveWindow(exeProcess.MainWindowHandle, 0, 0, 600, 400, true); }).Start(); } else if (message is LoLLauncher.RiotObjects.Platform.Game.Message.GameNotification) { } else if (message is LoLLauncher.RiotObjects.Platform.Matchmaking.SearchingForMatchNotification) { } else if (message is LoLLauncher.RiotObjects.Platform.Statistics.EndOfGameStats) { if (queueType == QueueTypes.CUSTOM) { CreatePracticeGame(); } else { updateStatus("Joining Queue"); LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams matchParams = new LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams(); 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"; } matchParams.QueueIds = new Int32[1] { (int)queueType }; LoLLauncher.RiotObjects.Platform.Matchmaking.SearchingForMatchNotification m = await connection.AttachToQueue(matchParams); if (m.PlayerJoinFailures == null) { updateStatus("Joined Queue"); } else { updateStatus("Couldn't enter Q - " + m.PlayerJoinFailures.Summoner.Name + " : " + m.PlayerJoinFailures.ReasonFailed); } } } else { if (message.ToString().Contains("EndOfGameStats")) { exeProcess.Kill(); LoLLauncher.RiotObjects.Platform.Statistics.EndOfGameStats eog = new LoLLauncher.RiotObjects.Platform.Statistics.EndOfGameStats(); connection_OnMessageReceived(sender, eog); } } }