When making software, programmers generally need to release the product multiple times. Sometimes these releases fixes critical bugs, add new features, or some other combination. One of the hardest things to do is to get the end-user to update software manually. So the easiest way to push an update is to let the software update itself! This tutorial will teach you the underlying principles behind adding an auto-update system, address various ways to achieve the feature, and various improvements that can be made after completion of this tutorial.
What You'll Need:
Some advantages of using Dropbox as a server are listed below:
Easy to setup
Receiving data from the server should be quick
Adding or changing data is as simple as type text into a plain text file
Some disadvantages of using Dropbox as a server are listed below:
Data cannot be updated from external applications (Only an owner can modify files in their Dropbox account)
Regardless of choice of server, another important aspect is the creation of a database. Some server may require the use of PhpMyAdmin or Linq databases, both of which contain fixed database structures. With respect to Dropbox, this "database" can simply be a plain text file with a fixed structure. A fixed database structure is required for efficient data by external programs. This information contained in this plain text file is what the application will receive. Sorting through to find the necessary data would be almost impossible unless the plain text file had a fixed structure.
If you are working with Dropbox simply create an account and upload a .txt file with any text in the file. You can practice retrieving the data through the Get Object in Multimedia Fusion 2 and Clickteam Fusion via the public (or private) link Dropbox provides for the .txt file.
The Get Object only supports the HTTP protocol. As such if the link Dropbox returns begins with https, the Get Object will not successfully receive the data. To correct this, simply exchange the "https" for "http".
Suppose we have a list of games (named GameA, GameB, GameC, etc) which contain auto-update features. If the details of the files were contained in a file, the text file may look like this:
GameA | Version 1.1 | www.MyUpdateLink.com | GameB | Version 71.01 | www.GameB.com/update | etc...
Retrieving and parsing the data should be as simple as possible. In this case the data structure of the text file is GameName| Version Number | GameUpdateLink with the | (pipe character) separating each field. We know that every third field after the first field is the name of a game, every third field after the second field is the game's version and so forth.
How could you reliably parse towards the right data if the file was structure random as demonstrated below?
GameA | www.GameB.com/update | GameB | Version 1.1 | Version 71.01 | www.MyUpdateLink.com | etc...
Without a fixed structure, knowing what each field represented would unnecessarily complicate things.
The picture to the left explains the logic behind the auto update process, Each rectangular element (starting at the green rectangle) represents a step.
1. The Main Application Starts
2. Receive and parse information for an update check
- If update is available, proceed to step 3
- If update is not available, end the update process and continue with Main Application
3. Download the newly Updated Application from the server
4. Download and open the "Switch Application"
5. Close Main Application
6. Overwrite/Switch the Main Application with the Updated Application
7. Remove the outdated Main Application (if an overwrite was not performed)
8. Close "Switch Application" and open the new Main Application
- Return to step 1.
The purpose of the "Switching Application" is to replace the "Main Application" with the "Updated Application."
The "Switching Application" is required because a file cannot be modified if said file is in use by the computer. As such we must close the "Main Application" and open the "Switch Application" so the "Switch Application" can overwrite the "Main Application" with the "Updated Application."
After the switch between the "Main Application" and the "Updated Application," the final act left is to open the "Updated Application" (which should have the exact name as the "Main Application") to repeat the process all over. If done properly, the application should not have an update available.
In summary, adding an auto-update feature to an application is simple! Just follow and implement these steps:
- Start the main application
- Perform the update check
- If update is available, continue with update process to step 3
- If update is unavailable, quit update process and continue with main application
- Download updated files
- Switch and overwrite the main application with the updated files
- Open the newly updated main application
- - Return to step 1
Keep in mind this tutorial does not cover all aspects of the auto-update process. You must code the application in case the user loses internet connection while downloading, the server is down, or other such hindering scenarios. You may even want to allow the user a choice for the update.
These considerations and more should be considered as you create the auto-update feature. Check out the Tutorial PDF at the top of the page for a deeper explanation the concepts behind this tutorial.