Skip to content

Simple Updater is a library created in C# and JAVA to help you building an Updater in few lines of code (for your game launcher or other project).

License

Notifications You must be signed in to change notification settings

e-n-0/Simple-Updater

Repository files navigation


contributions welcome Docs

Simple Updater is a library created to help you building an Updater in a few lines of code (for your game launcher or other projects).
This library is built in C# (.NET ≥ 4.6) and JAVA (JRE ≥ 1.8_80).
Just download the library, reference it to your project and you are good to go !
Check the documention bellow to start using it ! (An example project is provided in the source for each langage)

Features:

  • Developped both in C# and JAVA
  • No extra libraries ! All is native.
  • Easy integration
  • Keep the client updated with the server
  • Delete old or unwanted files that doesn't match with the server
  • Ignore list
  • Webclient configuration
  • Can cache the server result for x minutes/seconds (Optional - can have a long time response if disabled with a lot of files)
  • Trigger event for each step (Checking files, downloading, ...)
  • Status code
  • Download progression
  • Asynchronous download
  • Example projects fully commented

Any contribution is welcome !
Current Version: 1.1

Table of Contents

Installation

Web Server

You will need a webserver to host files that the updater will download.

  1. Clone/Download the project
  2. Upload files that are in 'PHP - Server files' to your webserver
  3. Check the index.php for configuration
  4. Create a folder named 'files' in the same directory as the index.php file
  5. Place all files that you want to download in that 'files' folder

Client integration

C#

  1. Go to the release page and download the Simple Updater library.
  2. Reference it in your project (Microsoft tutorial)
  3. Use the Object SimpleUpdater (see the documentation bellow)

JAVA

  1. Go to the release page and download the Simple Updater library.
  2. Add it in your project (A tutorial)
  3. Use the Object SimpleUpdater (see the documentation bellow)

Code documentation

Create the Simple Updater object.

// We will keep 'updater' on all the documentation
SimpleUpdater updater = new SimpleUpdater(server_url, installation_path);
Params Type Description
server_url string / String The url of the server on which files will be download
installation_path string / String The path where files will be downloaded (be careful if not set correctly it can delete wrong files)

Function: Check files from the server and delete outdated files (keep updated)

updater.CheckFilesFromServerAndDeleteOutdated();

Description: This function will contact the server to get all files and search through all local files and directories which files need to be deleted, downloaded or ignored. Files that needs to be deleted will be automaticaly deleted.

This function must be called before downloading files.

Function: Download files

updater.DownloadFiles();

Description: This will download all files that needs to be downloaded to the installation_path provided with the creation of the SimpleUpdater object.

Attributes of SimpleUpdater object

Name (C#) Function (JAVA) Type Description
Server_Url getServerUrl() string / String The url of the server on which files will be downloaded
Installation_path getInstallationPath() string / String The path where files will be download
CanDownload CanDownload() bool / Boolean Check whether you can start the download of files
CanCheck CanCheck() bool / Boolean Check whether you can start the verification process of local files
NumberOfBytesToDownload getNumberOfBytesToDownlaod() long Get the number of bytes that will be downloaded
StatusCode getStatusCode() int Get the status code

Events

Name Args Description
OnCheckFinished int nbrLocalFiles
int nbrServerFiles
int nbrFilesToDownload
int nbrFilesDeleted
long numberOfBytesToDownload
Event triggered when the verification process ends
OnDownloadFinished long TotalBytesDownloaded Event triggered when the download ends
OnDownloadProgressChanged long TotalBytesDownloaded
float percent
Event triggered each time the download progress changed
OnStatusChanged int code Event triggered when the status of the updater change

In the JAVA version you need to create a class and implement the SimpleUpdaterEvents class to it. Create an instance of this class and add it to listeners of SimpleUpdater Object with updater.addListener(yourEventClassObject).
Check the JAVA example project for more information.

Status code

Code Description
0 Waiting for action
1 Contacting server for files to parse
2 Search and delete local files
3 Check finished
Triggered after Check_Finished(...)
4 Download started
5 A file has been successfully downloaded
6 An error occurered when downloading a file
7 An error occured will trying to access the server
8 Download finished
Triggered after Download_Finished(...)

Example Projects

C#

The example project is fully commented. You can find it in C# - Example Project Simple Updater.

Screen

JAVA

This example project if fully commented. It prints debug to the console. You can find it in 'JAVA - Simple Updater Library'. Screen

Credit

  • en0 - Flavien Darche

License

MIT License