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();
            }
        }
Ejemplo n.º 4
0
        private void updateStatus()
        {
            List <Server> servers        = serverContainer.getServers();
            List <Server> iterateServers = new List <Server>(servers);

            for (int i = 0; i < iterateServers.Count; i++)
            {
                Server server = iterateServers[i];

                PingReply reply;
                bool      status = false;

                using (Ping ping = new Ping())
                {
                    try
                    {
                        reply  = ping.Send(URLFormatter.formatPingUrl(server.realmlist), 15);
                        status = reply.Status == IPStatus.Success;
                    } catch (Exception e) { }
                }

                serverContainer.updateStatus(server, status ? "Online" : "Offline");
            }
        }