Пример #1
0
        private void OnEndpointEvent(object src, EndpointEventArgs args)
        {
            if (args.EventType == "Update" && args.URI == "/lol-gameflow/v1/session")
            {
                var phase = args.JSON["phase"].Value <string>();

                if (phase == "EndOfGame" && downloadAllReplaysCheckbox.Checked)
                {
                    var gameId = args.JSON["gameData"]["gameId"].Value <long>();
                    try
                    {
                        QsoApi.DownloadReplay(gameId);
                        Console.WriteLine($"Downloading replay for game {gameId}");
                        trayIcon.ShowBalloonTip(2500, "Qso Client", "Downloading replay of your latest game!", ToolTipIcon.Info);
                        if (alertWhenManyReplaysCheckbox.Checked)
                        {
                            DirectoryInfo d = new DirectoryInfo(QsoApi.GetReplaysPath());
                            if (d.GetFiles().Length >= 50)
                            {
                                long size = 0;
                                d.GetFiles().Select(f => f.Length).ToList().ForEach(s => size += s);
                                MessageBox.Show($"Your replay folder currently contains {d.GetFiles().Length} files, sitting at {size / 1048576}MB. You should clean it out to save space on your drive.", "Replay Folder Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                    }
                    catch (QsoEndpointException)
                    {
                        trayIcon.ShowBalloonTip(2500, "Qso Client", "Failed to download latest replay.", ToolTipIcon.Error);
                    }
                }
                else if (phase == "ReadyCheck" && autoAcceptQueueCheckbox.Checked)
                {
                    QsoApi.AcceptQueue();
                }
            }
        }