一尘不染

应用程序启动器如何自我更新?

java

启动器在游戏中最常见。想想英雄联盟,星际争霸II或几乎所有的MMO。在开始实际游戏之前,您有一个小型启动器应用程序,负责更新和修补。

我想通过我正在开发的特定非游戏应用程序来朝这个方向发展。启动器的概念非常有意义:它检查更新,替换适当的二进制文件/库,运行完整性检查并启动应用程序。但是,启动器如何自我更新?这往往是罕见的事件,但是如何完成呢?启动程序实际上是否只是覆盖当前正在运行的二进制文件?还是下载后有某种交换步骤?我需要能够将(很少)更新发布到启动器(特别是如果我在启动器中发现一些错误)。

我的特定项目将是C#,但我对概念上相似的C ++和/或Java解决方案也感兴趣,以供将来参考。


阅读 238

收藏
2020-12-03

共1个答案

一尘不染

我从未尝试过,但这就是我的猜测(假设您无法覆盖正在执行的文件。如果可以,这一切都比较简单)

Updater A checks if its the newest version
If launcher isnt the newest version
    Download the differences (to save bandwidth) to file B
    Apply the delta to own code into file C
    Launch file C.
    Close
If file C exists (update happened recently)
    Try to delete C  (update was previous launch, delete temporary file)
    If delete fails  (We are C, means A is out of date)
        Copy C over A  (update launcher)
        Note that you can keep going, dont have to restart even though we are C.
If game isnt newest version
    Download the differences (to save bandwidth) to file B
    Apply the delta to game into file D
    delete game
    Rename D -> game
Run game
2020-12-03