예제 #1
0
        public void RequestPatches(AutoUpdateRequestType mode, PatchServer server)
        {
            if (!Kernel.HasAgreedPrivacy)
            {
                NoDownload(UpdateReturnMessage.PrivacyNotAccepted, false);
                return;
            }

            MsgRequestInfo msg = new MsgRequestInfo
            {
                Mode = mode
            };

            switch (mode)
            {
            case AutoUpdateRequestType.CheckForLauncherUpdates:
                msg.CurrentVersion = m_usClientVersion;
                break;

            case AutoUpdateRequestType.CheckForGameUpdates:
                msg.CurrentVersion = m_usCurrentVersion;
                break;
            }

            server.Send(msg);
        }
예제 #2
0
        /// <summary>
        ///     This method is invoked when the client has been approved of connecting to the server. The client should
        ///     be constructed in this method, and cipher algorithms should be initialized. If any packets need to be
        ///     sent in the connection state, they should be sent here.
        /// </summary>
        /// <param name="pState">Represents the status of an asynchronous operation.</param>
        public void Connect(AsynchronousState pState)
        {
            var pServer = new PatchServer(this, pState.Socket);

            pState.Client = pServer;

            Program.FrmMain.Edit(Program.FrmMain.lblCenterStatus, LabelAsyncOperation.Text, LanguageManager.GetString("StrCheckingPrivacyTerms"));

            MsgClientInfo msg = new MsgClientInfo();

            msg.MacAddress = Program.FrmMain.GetMacAddress();
            msg.Append(SystemProperties.GetObjects(MsgClientInfo.OPERATING_SYSTEM, MsgClientInfo.OperatingSystem).Values.ToArray());
            msg.Append(SystemProperties.GetObjects(MsgClientInfo.BASE_BOARD, MsgClientInfo.BaseBoard).Values.ToArray());
            msg.Append(SystemProperties.GetObjects(MsgClientInfo.PROCESSOR, MsgClientInfo.Processor).Values.ToArray());
            msg.Append(SystemProperties.GetObjects(MsgClientInfo.PHYSICAL_MEMORY, MsgClientInfo.PhysicalMemory).Values.ToArray());
            msg.Append(SystemProperties.GetObjects(MsgClientInfo.VIDEO_CONTROLLER, MsgClientInfo.VideoController).Values.ToArray());
            pServer.Send(msg);
        }
예제 #3
0
        public void PrepareToDownload(UpdateDownloadType type, List <string> strs, PatchServer server)
        {
            HideDownloadBar();
            if (strs.Count < 2)
            {
                if (type == UpdateDownloadType.UpdaterPatch)
                {
                    MsgRequestInfo mri = new MsgRequestInfo();
                    mri.CurrentVersion = m_usCurrentVersion;
                    server.Send(mri);

                    Kernel.Stage = AutoPatchStage.WaitingForGamePatchs;
                    Edit(lblCenterStatus, LabelAsyncOperation.Text,
                         LanguageManager.GetString("StrLookingForGameUpdates"));
                }
                else
                {
                    NoDownload(UpdateReturnMessage.Success);
                }

                return;
            }

            m_actuallyDownloading = type;
            Edit(lblCenterStatus, LabelAsyncOperation.Text, LanguageManager.GetString("StrCalculatingDownloadSize"));

            string domain = strs[0];

            if (!domain.EndsWith("/"))
            {
                domain += "/";
            }

            m_nTotalDownloadSize  = 0;
            m_nCurrentDownloading = 0;
            m_nTotalDownloads     = 0;

            Edit(lblDownloadStatus, LabelAsyncOperation.Text,
                 LanguageManager.GetString("StrLabelCalculatingDownloadAmount", m_nTotalDownloads,
                                           ParseFileSize(m_nTotalDownloadSize)));
            Edit(lblDownloadStatus, LabelAsyncOperation.Visible, true);

            for (int i = 1; i < strs.Count; i++)
            {
                if (!strs[i].EndsWith(".exe"))
                {
                    strs[i] += ".exe";
                }

                if (!RemoteFileExists($"{domain}{strs[i]}"))
                {
                    continue;
                }

                m_nTotalDownloadSize += FetchFileSize($"{domain}{strs[i]}");
                m_nTotalDownloads++;
                m_queueNextDownloads.Enqueue($"{domain}{strs[i]}");
                Edit(lblDownloadStatus, LabelAsyncOperation.Text,
                     LanguageManager.GetString("StrLabelCalculatingDownloadAmount", m_nTotalDownloads,
                                               ParseFileSize(m_nTotalDownloadSize)));
            }

            Edit(lblDownloadStatus, LabelAsyncOperation.Text,
                 LanguageManager.GetString("StrLabelCalculatingDownloadAmount", m_nTotalDownloads,
                                           ParseFileSize(m_nTotalDownloadSize)));
            Edit(pbDownload, ProgressBarAsyncOperation.Value, 0);
            Edit(pbDownload, ProgressBarAsyncOperation.Max, m_nTotalDownloadSize);
            ShowDownloadBar();
            StartDownloading();
        }