Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  updating game files from server  (Read 1372 times)
0 Members and 1 Guest are viewing this topic.
Offline thanatos1

Senior Newbie

« Posted 2013-01-20 18:06:56 »


I'm making a little game, which should have 2 Jars, one that runs first and whose job is to check the version of the client game and compare with the server version, if they differ i update the client files, if they're the same, i just run the application Jar.

I have a little server (only holds 20MB but that's fine for now), and I have a version.txt file which is what my updater compares the client version with.

My question is though, what would be a good way to determine which files to download and which ones are the same so don't bother downloading... my very barbaric solution was to check each and every single file from the server with each and every single file with the client but that's obviously not efficient.

Then I was thinking that perhaps each directory should have a version.txt file, so that if a directory version differs with the game, download the entire directory instead of the entire project, but that's still downloading stuff that i may not need.

Thank you for the help!
Offline Danny02
« Reply #1 - Posted 2013-01-20 20:09:28 »

take a look a hashing, a hash of a file like MD5 is a small number which is unique to this file.

So you can just have a list of the hash-numbers of all files on the server and the client then only have to check for three things:
-file exists only on client side -> delete
-file exists on both put hash differs from server-list -> update
-file exists only on server -> download

To even save you the time of calculating all the hashes on the client, you could just put a file for each version on the server which holds:
1. the previouse version
2. all the files which changed with this version

so the client just downloads all the version files it needs and then updates all the files which are listend in these lists
Offline thanatos1

Senior Newbie

« Reply #2 - Posted 2013-01-20 20:44:35 »

Let me see if i got this right.

I should have a list file on the server which holds all the checksums for all files, so it should kind of look like this:    8A9837D...ED1    [directory in the server, directory where to download to client]
   ...  1D09B82... DF8    [directory in the server, directory where to download to client]

and i traverse through it line by line.

if a is on the server but not on the client, i download that particular file
if a's checksum differs from the client's checksum, i download that particular file and delete the old one

so this means my project should have a static "createCheckSum(File file)" function that must be called everytime i create some changes to my code, and I pass to this all of my .java files so that it can populate this list.

Am i on the right track here or did I completely miss your point? sorry if i did!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Danny02
« Reply #3 - Posted 2013-01-20 20:52:03 »

yeah that is what I was talking about(you wouldn't need the directory info thou)
resources/images/gras.jpg 23A2DC23B2
resources/images/dirt.jpg 1DFE2343A2
resources/models/player.obj 7D32423322

But I probably would prefer my second idea. It is much more complicated but can be also more advanced.
This approach would be more like a little version control system(like git, svn). You could calculate patches between two version by comparing all the files and only providing the differences in diff files, which you then could pack into a zip file.
Offline Grunnt

JGO Kernel

Medals: 143
Projects: 8
Exp: 5 years

Complex != complicated

« Reply #4 - Posted 2013-01-22 10:34:45 »

You could also opt to use a framework such as GetDown which basically does precisely this for you (e.g. it also has tool for generating MD5 hashes into a digest.txt file in the format you describe).

Pages: [1]
  ignore  |  Print  

EgonOlsen (45 views)
2018-06-10 19:43:48

EgonOlsen (25 views)
2018-06-10 19:43:44

EgonOlsen (47 views)
2018-06-10 19:43:20

DesertCoockie (202 views)
2018-05-13 18:23:11

nelsongames (127 views)
2018-04-24 18:15:36

nelsongames (126 views)
2018-04-24 18:14:32

ivj94 (867 views)
2018-03-24 14:47:39

ivj94 (128 views)
2018-03-24 14:46:31

ivj94 (771 views)
2018-03-24 14:43:53

Solater (143 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!