public void downloadAndUpdateWwiseBanks() { GameDownloader downloadHelper = this; using (downloadHelper.wc) { string bankArchiveUrl = //"http://142.93.93.56/svn/timeloop/ReleaseWwiseBank.zip"; //"https://drive.google.com/uc?export=download&id=1OLk-C_iaI0ItswTyI_0yfc0ioo8BaqqE"; "https://drive.google.com/uc?export=download&id=14q1oOoVBWz2YZ-OPROvktOdTBIVdHTB1"; string downloadNameSuffix = XuFileUtil.GetDateSuffixForFileName(); downloadHelper.downloadedZipPath = Application.temporaryCachePath + "/" + downloadNameSuffix + "Audio.zip"; Debug.Log(downloadHelper.downloadedZipPath); downloadHelper.finished = false; downloadHelper.downloadPercentage = 0; downloadHelper.wc.DownloadProgressChanged += downloadHelper.wc_DownloadProgressChanged; downloadHelper.wc.DownloadFileCompleted += downloadHelper.Wc_DownloadDataCompleted; System.Uri uri = new System.Uri(bankArchiveUrl); Debug.Log(uri); downloadHelper.wc.DownloadFileAsync(uri, downloadHelper.downloadedZipPath); } }
public void TestCheckForUpdateAndDownloadUpdateWithAuthInvalidCachedCredentials() { Resources.InitUserDirectory("Console", false); //lets pretend that this game is already installed. FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Create(); FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").WriteText(ReadTextFile("console.json")); var newGameData = GenerateDataBlock(65536); var gameMd5 = GenerateMd5Hash(newGameData); SettingsManager.Instance.Settings = new GameSettings(); SettingsManager.Instance.Settings.GameUid = "Console"; SettingsManager.Instance.Settings.UserName = "******"; SettingsManager.Instance.Settings.Password = "******"; SettingsManager.Instance.Save(); ((MockHttpRequestManager)HttpRequestManager.Current).SetCredentials("http://www.junkship.net/downloads/console.zip", "user", "password1"); ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://www.junkship.net/downloads/console.zip", newGameData); ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://games.junkship.org/gamesource.asmx", @"{ ""latest"":{ ""version"":""1.1.2.4"", ""url"":""http://www.junkship.net/downloads/console.zip"", ""md5"":""" + gameMd5 + @""" } }"); Game game = new Game("c:\\program files\\MGDF\\game\\game.json"); var update = UpdateChecker.CheckForUpdate(game); Assert.IsNotNull(update); Assert.IsNotNull(update.Game); Assert.AreEqual("http://www.junkship.net/downloads/console.zip", update.Game.Url); Assert.AreEqual(gameMd5, update.Game.MD5); Assert.AreEqual("1.1.2.4", update.Game.Version); Assert.IsFalse(FileSystem.Current.GetFile("c:\\temp.zip").Exists); //now download the actual update. GameDownloader downloader = new GameDownloader(game, "http://www.junkship.net/downloads/console.zip", "c:\\temp.zip", gameMd5, args => { args.UserName = "******"; args.Password = "******"; return(true); }); downloader.Start(); Assert.AreEqual(SettingsManager.Instance.Settings.GameUid, "Console"); Assert.AreEqual(SettingsManager.Instance.Settings.UserName, "user"); Assert.AreEqual(SettingsManager.Instance.Settings.Password, "password1"); Assert.IsTrue(FileSystem.Current.GetFile("c:\\temp.zip").Exists); Assert.AreEqual(65536, FileSystem.Current.GetFile("c:\\temp.zip").Length); }
public void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else if (instance != this) { Destroy(gameObject); } }
protected override void StartInternal() { // do the checking if already installed game.Refresh(); if (game.IsInstalled) { status = ITaskStatus.SUCCESS; return; } // start the download task downloadTask = new GameDownloader(game); downloadTask.Start(); if (downloadTask.IsSuccess()) { Thread.Sleep(100); // check if folder already there // if download ready and OK, start install installTask = new InstallTask(game); installTask.Start(); status = installTask.Status(); statusMsg = installTask.StatusMsg(); // remove the zip file string fn = GardenConfig.Instance.GetPackedFilepath(game); if (fn != null && fn.Length > 0) { try { File.Delete(fn); } catch (Exception) { ; // TODO? } } } else { // error in downloading process - no install status = ITaskStatus.FAIL; statusMsg = downloadTask.StatusMsg(); } game.Refresh(); }
public void TestCheckForUpdateAndDownloadUpdateNoAuth() { //lets pretend that this game is already installed. FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Create(); FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").WriteText(ReadTextFile("console.json")); var newGameData = GenerateDataBlock(65536); var gameMd5 = GenerateMd5Hash(newGameData); ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://www.junkship.net/downloads/console.zip", newGameData); ((MockHttpRequestManager)HttpRequestManager.Current).ExpectResponse("http://games.junkship.org/gamesource.asmx", @"{ ""latest"":{ ""version"":""1.1.2.4"", ""url"":""http://www.junkship.net/downloads/console.zip"", ""md5"":""" + gameMd5 + @""" } }"); Game game = new Game("c:\\program files\\MGDF\\game\\game.json"); var update = UpdateChecker.CheckForUpdate(game); Assert.IsNotNull(update); Assert.IsNotNull(update.Game); Assert.AreEqual("http://www.junkship.net/downloads/console.zip", update.Game.Url); Assert.AreEqual(gameMd5, update.Game.MD5); Assert.AreEqual("1.1.2.4", update.Game.Version); Assert.IsFalse(FileSystem.Current.GetFile("c:\\temp.zip").Exists); //now download the actual update. GameDownloader downloader = new GameDownloader(game, "http://www.junkship.net/downloads/console.zip", "c:\\temp.zip", gameMd5, null); downloader.Start(); Assert.IsTrue(FileSystem.Current.GetFile("c:\\temp.zip").Exists); Assert.AreEqual(65536, FileSystem.Current.GetFile("c:\\temp.zip").Length); }
protected override void StartInternal() { // do the checking if already installed game.Refresh(); if (game.IsInstalled) { status = ITaskStatus.SUCCESS; return; } // start the download task downloadTask = new GameDownloader(game); downloadTask.Start(); if (downloadTask.IsSuccess()) { Thread.Sleep(100); // check if folder already there // if download ready and OK, start install installTask = new InstallTask(game); installTask.Start(); status = installTask.Status(); statusMsg = installTask.StatusMsg(); // install failed? remove the zip file and the game dir if (status == ITaskStatus.FAIL) { string fn = game.PackedFilePath; if (fn != null && fn.Length > 0) { try { File.Delete(fn); } catch (Exception) { ; // TODO? } } if (!game.IsBundleItem) { fn = game.GameFolder; if (fn != null && fn.Length > 0) { try { Directory.Delete(fn, true); } catch (Exception) { ; // TODO? } } } } } else { // error in downloading process - no install status = ITaskStatus.FAIL; statusMsg = downloadTask.StatusMsg(); } game.Refresh(); }