diff --git a/Giants.DataContract/Contracts/V1/GiantsVersion.cs b/Giants.DataContract/Contracts/V1/AppVersion.cs similarity index 91% rename from Giants.DataContract/Contracts/V1/GiantsVersion.cs rename to Giants.DataContract/Contracts/V1/AppVersion.cs index 6f63807..cdd7c1f 100644 --- a/Giants.DataContract/Contracts/V1/GiantsVersion.cs +++ b/Giants.DataContract/Contracts/V1/AppVersion.cs @@ -3,7 +3,7 @@ using System; using System.ComponentModel.DataAnnotations; - public class GiantsVersion + public class AppVersion { [Required] public int Build { get; set; } @@ -19,7 +19,7 @@ public override bool Equals(object obj) { - return obj is GiantsVersion info && + return obj is AppVersion info && Build == info.Build && Major == info.Major && Minor == info.Minor && diff --git a/Giants.DataContract/Contracts/V1/ServerInfo.cs b/Giants.DataContract/Contracts/V1/ServerInfo.cs index 796aa18..471642d 100644 --- a/Giants.DataContract/Contracts/V1/ServerInfo.cs +++ b/Giants.DataContract/Contracts/V1/ServerInfo.cs @@ -12,7 +12,7 @@ public string GameName { get; set; } [Required] - public GiantsVersion Version { get; set; } + public AppVersion Version { get; set; } [Required] [StringLength(100)] @@ -55,7 +55,7 @@ { return obj is ServerInfo info && GameName == info.GameName && - EqualityComparer.Default.Equals(Version, info.Version) && + EqualityComparer.Default.Equals(Version, info.Version) && SessionName == info.SessionName && Port == info.Port && MapName == info.MapName && diff --git a/Giants.DataContract/Contracts/V1/VersionInfo.cs b/Giants.DataContract/Contracts/V1/VersionInfo.cs index 6446024..bf5e3af 100644 --- a/Giants.DataContract/Contracts/V1/VersionInfo.cs +++ b/Giants.DataContract/Contracts/V1/VersionInfo.cs @@ -6,15 +6,12 @@ public class VersionInfo { [Required] - public string GameName { get; set; } + public string AppName { get; set; } [Required] - public GiantsVersion GameVersion { get; set; } + public AppVersion Version { get; set; } [Required] - public GiantsVersion LauncherVersion { get; set; } - - [Required] - public Uri PatchUri { get; set; } + public Uri InstallerUri { get; set; } } } diff --git a/Giants.Launcher/LauncherForm.cs b/Giants.Launcher/LauncherForm.cs index e1eaa84..f206d35 100644 --- a/Giants.Launcher/LauncherForm.cs +++ b/Giants.Launcher/LauncherForm.cs @@ -4,7 +4,10 @@ using System.Diagnostics; using System.IO; using System.Media; using System.Net; +using System.Net.Http; +using System.Threading.Tasks; using System.Windows.Forms; +using Giants.WebApi.Clients; using Microsoft.Win32; namespace Giants.Launcher @@ -12,23 +15,27 @@ namespace Giants.Launcher public partial class LauncherForm : Form { // Constant settings - const string GAME_NAME = "Giants: Citizen Kabuto"; - const string GAME_PATH = "GiantsMain.exe"; - const string REGISTRY_KEY = @"HKEY_CURRENT_USER\Software\PlanetMoon\Giants"; - const string REGISTRY_VALUE = "DestDir"; - const string UPDATE_URL = @"https://google.com"; // update me + private const string GAME_NAME = "Giants: Citizen Kabuto"; + private const string GAME_PATH = "GiantsMain.exe"; + private const string REGISTRY_KEY = @"HKEY_CURRENT_USER\Software\PlanetMoon\Giants"; + private const string REGISTRY_VALUE = "DestDir"; + private const string UPDATE_URL = @"https://google.com"; // update me + private readonly VersionClient httpClient; - string _commandLine = String.Empty; - string _gamePath = null; - Updater _Updater; + private string commandLine = String.Empty; + private string gamePath = null; + private Updater updater; public LauncherForm() { this.InitializeComponent(); - // Set window title - this.Text = GAME_NAME; - } + // Set window title + this.Text = GAME_NAME; + + this.httpClient = new VersionClient(new HttpClient()); + this.httpClient.BaseUrl = "https://giants.azurewebsites.net"; + } private void btnExit_Click(object sender, EventArgs e) { @@ -40,48 +47,49 @@ namespace Giants.Launcher GameSettings.Save(); foreach (string c in Environment.GetCommandLineArgs()) - this._commandLine = this._commandLine + c + " "; + { + this.commandLine = this.commandLine + c + " "; + } - string commandLine = string.Format("{0} -launcher", this._commandLine.Trim()); + string commandLine = string.Format("{0} -launcher", this.commandLine.Trim()); try { Process gameProcess = new Process(); gameProcess.StartInfo.Arguments = commandLine; - gameProcess.StartInfo.FileName = this._gamePath; - gameProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(this._gamePath); + gameProcess.StartInfo.FileName = this.gamePath; + gameProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(this.gamePath); gameProcess.Start(); Application.Exit(); } catch(Exception ex) { - MessageBox.Show(string.Format("Failed to launch game process at: {0}. {1}", this._gamePath, ex.Message), + MessageBox.Show(string.Format("Failed to launch game process at: {0}. {1}", this.gamePath, ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void btnOptions_Click(object sender, EventArgs e) { - OptionsForm form = new OptionsForm(GAME_NAME + " Options", this._gamePath); + OptionsForm form = new OptionsForm(GAME_NAME + " Options", this.gamePath); - //form.MdiParent = this; form.ShowDialog(); } - private void LauncherForm_Load(object sender, EventArgs e) + private async void LauncherForm_Load(object sender, EventArgs e) { // Find the game executable, first looking for it relative to our current directory and then // using the registry path if that fails. - this._gamePath = Path.GetDirectoryName(Application.ExecutablePath) + "\\" + GAME_PATH; - if (!File.Exists(this._gamePath)) + this.gamePath = Path.GetDirectoryName(Application.ExecutablePath) + "\\" + GAME_PATH; + if (!File.Exists(this.gamePath)) { - this._gamePath = (string)Registry.GetValue(REGISTRY_KEY, REGISTRY_VALUE, null); - if (this._gamePath != null) - this._gamePath = Path.Combine(this._gamePath, GAME_PATH); + this.gamePath = (string)Registry.GetValue(REGISTRY_KEY, REGISTRY_VALUE, null); + if (this.gamePath != null) + this.gamePath = Path.Combine(this.gamePath, GAME_PATH); - if (this._gamePath == null || !File.Exists(this._gamePath)) + if (this.gamePath == null || !File.Exists(this.gamePath)) { string message = string.Format(Resources.AppNotFound, GAME_NAME); MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -94,7 +102,7 @@ namespace Giants.Launcher try { - FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(this._gamePath); + FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(this.gamePath); gameVersion = new Version(fvi.FileVersion.Replace(',', '.')); } finally @@ -108,16 +116,50 @@ namespace Giants.Launcher } // Read game settings from registry - GameSettings.Load(this._gamePath); + GameSettings.Load(this.gamePath); if ((int)GameSettings.Get("NoAutoUpdate") == 0) { // Check for updates - this._Updater = new Updater(new Uri(UPDATE_URL), gameVersion); - this._Updater.DownloadUpdateInfo(this.LauncherForm_DownloadCompletedCallback, this.LauncherForm_DownloadProgressCallback); + this.updater = new Updater( + appVersion: gameVersion, + updateCompletedCallback: this.LauncherForm_DownloadCompletedCallback, + updateProgressCallback: this.LauncherForm_DownloadProgressCallback); + + Task gameVersionInfo = this.GetVersionInfo("Giants"); + Task launcherVersionInfo = this.GetVersionInfo("GiantsLauncher"); + + await Task.WhenAll(gameVersionInfo, launcherVersionInfo); + + await this.updater.UpdateApplication(ApplicationType.Game, gameVersionInfo.Result); + await this.updater.UpdateApplication(ApplicationType.Launcher, launcherVersionInfo.Result); } } + private async Task GetVersionInfo(string appName) + { + VersionInfo versionInfo; + try + { + versionInfo = await this.httpClient.GetVersionInfoAsync(appName); + return versionInfo; + } + catch (ApiException ex) + { +#if DEBUG + MessageBox.Show($"Exception retrieving version information: {ex.StatusCode}"); +#endif + return null; + } + catch (Exception ex) + { +#if DEBUG + MessageBox.Show($"Exception retrieving version information: {ex.Message}"); +#endif + return null; + } + } + private void LauncherForm_MouseDown(object sender, MouseEventArgs e) { // Force window to be draggable even though we have no menu bar @@ -143,7 +185,9 @@ namespace Giants.Launcher private void LauncherForm_DownloadCompletedCallback(object sender, AsyncCompletedEventArgs e) { if (e.Cancelled) + { return; + } this.updateProgressBar.Value = 0; this.updateProgressBar.Visible = false; @@ -164,15 +208,15 @@ namespace Giants.Launcher // Start the installer process Process updaterProcess = new Process(); - updaterProcess.StartInfo.FileName = Path.Combine(Path.GetTempPath(), updateInfo.FileName); + updaterProcess.StartInfo.FileName = updateInfo.FilePath; updaterProcess.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory(); - if (updateInfo.UpdateType == UpdateType.Game) + if (updateInfo.ApplicationType == ApplicationType.Game) { // Default installation directory to current directory updaterProcess.StartInfo.Arguments = string.Format("/D {0}", Path.GetDirectoryName(Application.ExecutablePath)); } - else if (updateInfo.UpdateType == UpdateType.Launcher) + else if (updateInfo.ApplicationType == ApplicationType.Launcher) { // Default installation directory to current directory and launch a silent install updaterProcess.StartInfo.Arguments = string.Format("/S /D {0}", Path.GetDirectoryName(Application.ExecutablePath)); @@ -195,5 +239,5 @@ namespace Giants.Launcher this.txtProgress.Visible = true; this.txtProgress.Text = string.Format(Resources.DownloadProgress, e.ProgressPercentage, (info.FileSize / 1024) / 1024); } - } + } } diff --git a/Giants.Launcher/Updater/UpdateType.cs b/Giants.Launcher/Updater/ApplicationType.cs similarity index 64% rename from Giants.Launcher/Updater/UpdateType.cs rename to Giants.Launcher/Updater/ApplicationType.cs index 2dcaa98..f8fc387 100644 --- a/Giants.Launcher/Updater/UpdateType.cs +++ b/Giants.Launcher/Updater/ApplicationType.cs @@ -1,6 +1,6 @@ namespace Giants.Launcher { - public enum UpdateType + public enum ApplicationType { Launcher, Game, diff --git a/Giants.Launcher/Updater/UpdateInfo.cs b/Giants.Launcher/Updater/UpdateInfo.cs index 9b90304..2740167 100644 --- a/Giants.Launcher/Updater/UpdateInfo.cs +++ b/Giants.Launcher/Updater/UpdateInfo.cs @@ -5,24 +5,8 @@ namespace Giants.Launcher { public class UpdateInfo { - public Version VersionFrom { get; set; } - public Version VersionTo { get; set; } - public Uri DownloadUri - { - get - { - return this.downloadUri; - } - set - { - this.downloadUri = value; - this.FileName = Path.GetFileName(value.AbsoluteUri); - } - } public int FileSize { get; set; } - public string FileName { get; set; } - public UpdateType UpdateType { get; set; } - - private Uri downloadUri; + public string FilePath { get; set; } + public ApplicationType ApplicationType { get; set; } } } diff --git a/Giants.Launcher/Updater/Updater.cs b/Giants.Launcher/Updater/Updater.cs index eb13965..aa548ad 100644 --- a/Giants.Launcher/Updater/Updater.cs +++ b/Giants.Launcher/Updater/Updater.cs @@ -1,37 +1,43 @@ using System; using System.ComponentModel; using System.IO; -using System.Linq; using System.Net; +using System.Threading.Tasks; using System.Windows.Forms; -using System.Xml.Linq; +using Giants.WebApi.Clients; namespace Giants.Launcher { public class Updater { - private readonly Uri updateUri; private readonly Version appVersion; - private AsyncCompletedEventHandler updateCompletedCallback; - private DownloadProgressChangedEventHandler updateProgressCallback; + private readonly AsyncCompletedEventHandler updateCompletedCallback; + private readonly DownloadProgressChangedEventHandler updateProgressCallback; - public Updater(Uri updateUri, Version appVersion) + public Updater( + Version appVersion, + AsyncCompletedEventHandler updateCompletedCallback, + DownloadProgressChangedEventHandler updateProgressCallback) { - this.updateUri = updateUri; this.appVersion = appVersion; - } - public void DownloadUpdateInfo(AsyncCompletedEventHandler downloadCompleteCallback, DownloadProgressChangedEventHandler downloadProgressCallback) + this.updateCompletedCallback = updateCompletedCallback; + this.updateProgressCallback = updateProgressCallback; + } + + public Task UpdateApplication(ApplicationType applicationType, VersionInfo versionInfo) { - WebClient client = new WebClient(); + try + { + if (this.ToVersion(versionInfo.Version) > this.appVersion) + { + this.StartApplicationUpdate(applicationType, versionInfo); + } + } + catch (Exception) + { + } - // Keep track of our progress callbacks - this.updateCompletedCallback = downloadCompleteCallback; - this.updateProgressCallback = downloadProgressCallback; - - // Download update info XML - client.Proxy = null; - client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(this.DownloadDataCallback); - client.DownloadDataAsync(this.updateUri); + return Task.CompletedTask; } private int GetHttpFileSize(Uri uri) @@ -52,125 +58,53 @@ namespace Giants.Launcher } - private void StartGameUpdate(XElement root, Version currentVersion) + private void StartApplicationUpdate(ApplicationType applicationType, VersionInfo versionInfo) { - var updates = from update in root.Elements("Update") - select new UpdateInfo() - { - VersionFrom = new Version(update.Attribute("FromVersion").Value), - VersionTo = new Version(update.Attribute("ToVersion").Value), - DownloadUri = new Uri(update.Attribute("Url").Value), - UpdateType = UpdateType.Game - }; - - // Grab the download path for the update to our current version, otherwise fall back to the full installer - // (specially defined as FromVersion 0.0.0.0 in the XML) - UpdateInfo info = updates.FirstOrDefault(update => update.VersionFrom == currentVersion); - if (info == null) - info = updates.Single(update => update.VersionFrom == new Version("0.0.0.0")); - // Display update prompt - string updateMsg = string.Format(Resources.UpdateAvailableText, info.VersionTo.ToString()); - if (MessageBox.Show(updateMsg, Resources.UpdateAvailableTitle, MessageBoxButtons.YesNo) == DialogResult.No) - return; // User declined update + string updateMsg = applicationType == ApplicationType.Game ? + string.Format(Resources.UpdateAvailableText, this.ToVersion(versionInfo.Version).ToString()) : + string.Format(Resources.LauncherUpdateAvailableText, this.ToVersion(versionInfo.Version).ToString()); - string path = Path.Combine(Path.GetTempPath(), info.FileName); + if (MessageBox.Show(updateMsg, Resources.UpdateAvailableTitle, MessageBoxButtons.YesNo) == DialogResult.No) + { + return; // User declined update + } + + string patchFileName = Path.GetFileName(versionInfo.InstallerUri.AbsoluteUri); + string localPath = Path.Combine(Path.GetTempPath(), patchFileName); // Delete the file locally if it already exists, just to be safe - if (File.Exists(path)) - File.Delete(path); + if (File.Exists(localPath)) + { + File.Delete(localPath); + } - info.FileSize = this.GetHttpFileSize(info.DownloadUri); - if (info.FileSize == -1) + int fileSize = this.GetHttpFileSize(versionInfo.InstallerUri); + if (fileSize == -1) { string errorMsg = string.Format(Resources.UpdateDownloadFailedText, "File not found on server."); MessageBox.Show(errorMsg, Resources.UpdateDownloadFailedTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - - // Download the update - WebClient client = new WebClient() + var updateInfo = new UpdateInfo() { - Proxy = null + FilePath = localPath, + FileSize = fileSize, + ApplicationType = applicationType }; - client.DownloadFileAsync(info.DownloadUri, path, info); + + // Download the update + // TODO: Super old code, replace this with async HttpClient + WebClient client = new WebClient(); + client.DownloadFileAsync(versionInfo.InstallerUri, localPath, updateInfo); client.DownloadFileCompleted += this.updateCompletedCallback; client.DownloadProgressChanged += this.updateProgressCallback; } - private void StartLauncherUpdate(XElement root) + private Version ToVersion(AppVersion version) { - var query = from update in root.Descendants("LauncherUpdate") - select new UpdateInfo() - { - VersionTo = new Version(update.Attribute("ToVersion").Value), - DownloadUri = new Uri(update.Attribute("Url").Value), - UpdateType = UpdateType.Launcher - }; - - UpdateInfo info = query.FirstOrDefault(); - - // Display update prompt - string updateMsg = string.Format(Resources.LauncherUpdateAvailableText, info.VersionTo.ToString()); - if (MessageBox.Show(updateMsg, Resources.UpdateAvailableTitle, MessageBoxButtons.YesNo) == DialogResult.No) - return; // User declined update - - string path = Path.Combine(Path.GetTempPath(), info.FileName); - - // Delete the file locally if it already exists, just to be safe - if (File.Exists(path)) - File.Delete(path); - - info.FileSize = this.GetHttpFileSize(info.DownloadUri); - if (info.FileSize == -1) - { - string errorMsg = string.Format(Resources.UpdateDownloadFailedText, "File not found on server."); - MessageBox.Show(errorMsg, Resources.UpdateDownloadFailedTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - - // Download the update - WebClient client = new WebClient() - { - Proxy = null - }; - client.DownloadFileAsync(info.DownloadUri, path, info); - client.DownloadFileCompleted += this.updateCompletedCallback; - client.DownloadProgressChanged += this.updateProgressCallback; + return new Version(version.Major, version.Minor, version.Build, version.Revision); } - - private void DownloadDataCallback(Object sender, DownloadDataCompletedEventArgs e) - { - try - { - if (!e.Cancelled && e.Error == null) - { - byte[] data = (byte[])e.Result; - string textData = System.Text.Encoding.UTF8.GetString(data); - - XElement root = XElement.Parse(textData); - - Version launcherVersion = new Version(root.Attribute("CurrentLauncherVersion").Value); - Version gameVersion = new Version(root.Attribute("CurrentGameVersion").Value); - - Version ourVersion = new Version(Application.ProductVersion); - if (launcherVersion > ourVersion) - { - this.StartLauncherUpdate(root); - return; - } - else if (gameVersion > this.appVersion) - this.StartGameUpdate(root, this.appVersion); - } - } - - catch (Exception ex) - { -#if DEBUG - MessageBox.Show(string.Format("Exception in DownloadDataCallback: {0}", ex.Message)); -#endif - } - } - } + } } diff --git a/Giants.Services/Core/Entities/VersionInfo.cs b/Giants.Services/Core/Entities/VersionInfo.cs index da2a378..1064547 100644 --- a/Giants.Services/Core/Entities/VersionInfo.cs +++ b/Giants.Services/Core/Entities/VersionInfo.cs @@ -4,7 +4,7 @@ namespace Giants.Services { public class VersionInfo : DataContract.VersionInfo, IIdentifiable { - public string id => GenerateId(this.GameName); + public string id => GenerateId(this.AppName); public string DocumentType => nameof(VersionInfo); diff --git a/Giants.Services/Services/UpdaterService.cs b/Giants.Services/Services/UpdaterService.cs index f9689b1..6857dbf 100644 --- a/Giants.Services/Services/UpdaterService.cs +++ b/Giants.Services/Services/UpdaterService.cs @@ -11,11 +11,11 @@ namespace Giants.Services this.updaterStore = updaterStore; } - public async Task GetVersionInfo(string gameName) + public async Task GetVersionInfo(string appName) { - ArgumentUtility.CheckStringForNullOrEmpty(gameName, nameof(gameName)); + ArgumentUtility.CheckStringForNullOrEmpty(appName, nameof(appName)); - return await this.updaterStore.GetVersionInfo(gameName); + return await this.updaterStore.GetVersionInfo(appName); } } } diff --git a/Giants.Services/Store/CosmosDbUpdaterStore.cs b/Giants.Services/Store/CosmosDbUpdaterStore.cs index 8c8d5e9..2e72b79 100644 --- a/Giants.Services/Store/CosmosDbUpdaterStore.cs +++ b/Giants.Services/Store/CosmosDbUpdaterStore.cs @@ -23,16 +23,16 @@ this.configuration = configuration; } - public async Task GetVersionInfo(string gameName) + public async Task GetVersionInfo(string appName) { VersionInfo versionInfo = await this.memoryCache.GetOrCreateAsync( - key: GetCacheKey(gameName), + key: GetCacheKey(appName), factory: async (entry) => { entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5); return await this.client.GetItemById( - VersionInfo.GenerateId(gameName), + VersionInfo.GenerateId(appName), nameof(VersionInfo)); }); diff --git a/Giants.Services/Store/FileUpdaterStore.cs b/Giants.Services/Store/FileUpdaterStore.cs index acc9284..b223c49 100644 --- a/Giants.Services/Store/FileUpdaterStore.cs +++ b/Giants.Services/Store/FileUpdaterStore.cs @@ -5,7 +5,7 @@ public class FileUpdaterStore : IUpdaterStore { - public Task GetVersionInfo(string gameName) + public Task GetVersionInfo(string appName) { throw new NotImplementedException(); } diff --git a/Giants.Services/Store/IUpdaterStore.cs b/Giants.Services/Store/IUpdaterStore.cs index c87bfcf..f577543 100644 --- a/Giants.Services/Store/IUpdaterStore.cs +++ b/Giants.Services/Store/IUpdaterStore.cs @@ -4,7 +4,7 @@ public interface IUpdaterStore { - Task GetVersionInfo(string gameName); + Task GetVersionInfo(string appName); Task Initialize(); } diff --git a/Giants.WebApi.Clients/Clients.cs b/Giants.WebApi.Clients/Clients.cs index 60e4b2d..647b411 100644 --- a/Giants.WebApi.Clients/Clients.cs +++ b/Giants.WebApi.Clients/Clients.cs @@ -48,20 +48,20 @@ namespace Giants.WebApi.Clients partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); /// A server side error occurred. - public System.Threading.Tasks.Task GetVersionInfoAsync(string gameName) + public System.Threading.Tasks.Task GetVersionInfoAsync(string appName) { - return GetVersionInfoAsync(gameName, System.Threading.CancellationToken.None); + return GetVersionInfoAsync(appName, System.Threading.CancellationToken.None); } /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// A server side error occurred. - public async System.Threading.Tasks.Task GetVersionInfoAsync(string gameName, System.Threading.CancellationToken cancellationToken) + public async System.Threading.Tasks.Task GetVersionInfoAsync(string appName, System.Threading.CancellationToken cancellationToken) { var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/Version?"); - if (gameName != null) + if (appName != null) { - urlBuilder_.Append(System.Uri.EscapeDataString("gameName") + "=").Append(System.Uri.EscapeDataString(ConvertToString(gameName, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Append(System.Uri.EscapeDataString("appName") + "=").Append(System.Uri.EscapeDataString(ConvertToString(appName, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); } urlBuilder_.Length--; @@ -550,27 +550,23 @@ namespace Giants.WebApi.Clients [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.24.0 (Newtonsoft.Json v11.0.0.0)")] public partial class VersionInfo { - [Newtonsoft.Json.JsonProperty("gameName", Required = Newtonsoft.Json.Required.Always)] + [Newtonsoft.Json.JsonProperty("appName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] - public string GameName { get; set; } + public string AppName { get; set; } - [Newtonsoft.Json.JsonProperty("gameVersion", Required = Newtonsoft.Json.Required.Always)] + [Newtonsoft.Json.JsonProperty("version", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] - public GiantsVersion GameVersion { get; set; } = new GiantsVersion(); + public AppVersion Version { get; set; } = new AppVersion(); - [Newtonsoft.Json.JsonProperty("launcherVersion", Required = Newtonsoft.Json.Required.Always)] + [Newtonsoft.Json.JsonProperty("installerUri", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] - public GiantsVersion LauncherVersion { get; set; } = new GiantsVersion(); - - [Newtonsoft.Json.JsonProperty("patchUri", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.Uri PatchUri { get; set; } + public System.Uri InstallerUri { get; set; } } [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.24.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class GiantsVersion + public partial class AppVersion { [Newtonsoft.Json.JsonProperty("build", Required = Newtonsoft.Json.Required.Always)] public int Build { get; set; } @@ -607,7 +603,7 @@ namespace Giants.WebApi.Clients [Newtonsoft.Json.JsonProperty("version", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] - public GiantsVersion Version { get; set; } = new GiantsVersion(); + public AppVersion Version { get; set; } = new AppVersion(); [Newtonsoft.Json.JsonProperty("sessionName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] diff --git a/Giants.WebApi.Clients/swagger.json b/Giants.WebApi.Clients/swagger.json index 79a78e7..3076fb1 100644 --- a/Giants.WebApi.Clients/swagger.json +++ b/Giants.WebApi.Clients/swagger.json @@ -19,7 +19,7 @@ "operationId": "Version_GetVersionInfo", "parameters": [ { - "name": "gameName", + "name": "appName", "in": "query", "schema": { "type": "string", @@ -106,30 +106,26 @@ "type": "object", "additionalProperties": false, "required": [ - "gameName", - "gameVersion", - "launcherVersion", - "patchUri" + "appName", + "version", + "installerUri" ], "properties": { - "gameName": { + "appName": { "type": "string", "minLength": 1 }, - "gameVersion": { - "$ref": "#/components/schemas/GiantsVersion" + "version": { + "$ref": "#/components/schemas/AppVersion" }, - "launcherVersion": { - "$ref": "#/components/schemas/GiantsVersion" - }, - "patchUri": { + "installerUri": { "type": "string", "format": "uri", "minLength": 1 } } }, - "GiantsVersion": { + "AppVersion": { "type": "object", "additionalProperties": false, "required": [ @@ -202,7 +198,7 @@ "minLength": 0 }, "version": { - "$ref": "#/components/schemas/GiantsVersion" + "$ref": "#/components/schemas/AppVersion" }, "sessionName": { "type": "string", diff --git a/Giants.WebApi/Controllers/VersionController.cs b/Giants.WebApi/Controllers/VersionController.cs index 5da66d9..2f4b453 100644 --- a/Giants.WebApi/Controllers/VersionController.cs +++ b/Giants.WebApi/Controllers/VersionController.cs @@ -22,9 +22,9 @@ namespace Giants.WebApi.Controllers } [HttpGet] - public async Task GetVersionInfo(string gameName) + public async Task GetVersionInfo(string appName) { - Services.VersionInfo versionInfo = await this.updaterService.GetVersionInfo(gameName); + Services.VersionInfo versionInfo = await this.updaterService.GetVersionInfo(appName); return mapper.Map(versionInfo); }