public override int WriteTo(byte[] Buffer, int StartIndex = 0) { int cursor = StartIndex; cursor += base.WriteTo(Buffer, cursor); cursor += ClientPatchInfo.WriteTo(Buffer, cursor); return(cursor - StartIndex); }
public override int ReadFrom(byte[] Buffer, int StartIndex = 0) { int cursor = StartIndex; cursor += base.ReadFrom(Buffer, cursor); ClientPatchInfo = new ClientPatchInfo(Buffer, cursor); cursor += ClientPatchInfo.ByteLength; return(cursor - StartIndex); }
private void OnUpdaterDownloadCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Error != null || e.Cancelled == true) { if (DownloadText != null) { DownloadText(this, new StringEventArgs(DOWNLOADFAIL)); } return; } // get attached userdata ClientPatchInfo info = (ClientPatchInfo)e.UserState; // write patcher data File.WriteAllLines(DEFAULTUPDATEFILEPATH + URLDATAFILE, new string[] { info.GetUpdateBasePath(), info.GetJsonDataURL() }); // startup patcher string clientExec = Assembly.GetEntryAssembly().Location; string clientPath = Path.GetDirectoryName(clientExec); ProcessStartInfo pi = new ProcessStartInfo(); pi.FileName = Path.Combine(clientPath, DEFAULTUPDATEFILEPATH, info.UpdaterFile); pi.WorkingDirectory = Path.Combine(clientPath, DEFAULTUPDATEFILEPATH); pi.Arguments = ""; pi.UseShellExecute = true; Process process = new Process(); process.StartInfo = pi; process.Start(); if (DownloadFinished != null) { DownloadFinished(this, new StringEventArgs(SUCCESSMESSAGE)); } if (ExitRequestEvent != null) { ExitRequestEvent(this, new EventArgs()); } }
/// <summary> /// Downloads the current version of the game patcher. /// Once done the client quits and the patcher launches. /// </summary> /// <param name="ClientPatchInfo"></param> public void DownloadClientPatcher(ClientPatchInfo ClientPatchInfo) { if (DownloadStarted != null) { DownloadStarted(this, new EventArgs()); } // Set download progress to 0%. if (DownloadProgress != null) { DownloadProgress(this, new IntegerEventArgs(0)); } WebClient webClient = new WebClient(); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(OnUpdaterDownloadCompleted); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(OnUpdaterDownloadProgressChanged); // Update UI with download info. if (DownloadText != null) { DownloadText(this, new StringEventArgs("Downloading Patcher")); } try { // Start downloading the file webClient.DownloadFileAsync(new Uri(ClientPatchInfo.GetUpdaterURL()), DEFAULTUPDATEFILEPATH + ClientPatchInfo.UpdaterFile, ClientPatchInfo); } catch (Exception ex) { // Update UI with failed web download message. if (DownloadText != null) { DownloadText(this, new StringEventArgs("Error: " + ex.Message)); } } }
public ClientPatchMessage(ClientPatchInfo ClientPatchInfo) : base(MessageTypeLoginMode.ClientPatch) { this.ClientPatchInfo = ClientPatchInfo; }
public unsafe override void WriteTo(ref byte *Buffer) { base.WriteTo(ref Buffer); ClientPatchInfo.WriteTo(ref Buffer); }
public unsafe override void ReadFrom(ref byte *Buffer) { base.ReadFrom(ref Buffer); ClientPatchInfo = new ClientPatchInfo(ref Buffer); }