Ejemplo n.º 1
0
        public void downloadPatch(Patch patch)
        {
            string downloadURL = URLFormatter.format($"{serverToDownload.website}/{serverToDownload.downloadDirectory}/");

            using (WebClient webClient = new WebClient())
            {
                string patchDownloadURL = downloadURL + "/" + patch.fileName;
                if (!ResourceHelper.resourceExists(patchDownloadURL))
                {
                    form.downloadStatusLabel.Text = $"Status: Could not download {patch.fileName} - It does not exist";
                    return;
                }

                ApplicationStatus.downloading = true;

                string localPatchDirectory = $"{serverToDownload.clientDirectory}/Data/";
                string localPatchPath      = localPatchDirectory + patch.fileName;

                if (!Directory.Exists(localPatchDirectory))
                {
                    Directory.CreateDirectory(localPatchDirectory);
                }

                webClient.DownloadProgressChanged += downloadPatchProgressChanged;
                webClient.DownloadFileAsync(new System.Uri(patchDownloadURL), localPatchPath);
                webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(this.downloadPatchCompleted);
                stopWatch.Start();

                patchesToDownload.Remove(patch);
            }
        }
Ejemplo n.º 2
0
        public void patch(Server server)
        {
            serverToDownload = server;

            if (ApplicationStatus.oldServer != null && shouldMoveAway)
            {
                PatchMover.moveAway((Server)ApplicationStatus.oldServer);
            }
            else if (!shouldMoveAway)
            {
                shouldMoveAway = true;
            }

            using (WebClient webClient = new WebClient())
            {
                string patchFileURL = URLFormatter.format($"{server.website}/{server.downloadDirectory}/patchfile.dat");

                if (server.downloadDirectory == string.Empty || server.patchesDirectory == string.Empty ||
                    !ResourceHelper.resourceExists(patchFileURL))
                {
                    form.downloadStatusLabel.Text = "Status: Server does not support the launcher's patcher";
                    form.playButton.Text          = "Play";
                    form.playButton.Enabled       = true;
                    ApplicationStatus.downloading = false;
                    return;
                }

                ApplicationStatus.downloading = true;

                webClient.DownloadProgressChanged += downloadPatchProgressChanged;
                webClient.DownloadFileAsync(new System.Uri(patchFileURL), "patchfile.dat");
                webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(this.downloadPatchFileCompleted);
            }
        }
Ejemplo n.º 3
0
        public void downloadServer(string url, string directoryPath)
        {
            this.directoryPath = directoryPath;

            using (WebClient webClient = new WebClient())
            {
                if (!ResourceHelper.resourceExists(URLFormatter.format(url) + "/server.dat"))
                {
                    MessageBox.Show("Server does not support the launcher's simple setup", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                webClient.DownloadProgressChanged += downloadServerProgressChanged;
                webClient.DownloadFileAsync(new System.Uri(URLFormatter.format(url) + "/server.dat"), "server.dat");
                webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(this.downloadServerCompleted);
                stopWatch.Reset();
                stopWatch.Start();
            }
        }