Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (562)
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 532 times)
0 Members and 2 Guests are viewing this topic.
Offline thanatos1

Senior Newbie





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

Hello,

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:
item.java    8A9837D...ED1    [directory in the server, directory where to download to client]
   ...
dude.java  1D09B82... DF8    [directory in the server, directory where to download to client]

and i traverse through it line by line.

if a x.java is on the server but not on the client, i download that particular file
if a x.java'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)
like:
1  
2  
3  
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 Wizard


Medals: 69
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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (25 views)
2014-09-21 02:42:18

BurntPizza (17 views)
2014-09-21 01:30:30

moogie (19 views)
2014-09-21 00:26:15

UprightPath (26 views)
2014-09-20 20:14:06

BurntPizza (29 views)
2014-09-19 03:14:18

Dwinin (44 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (100 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56

mitcheeb (71 views)
2014-09-08 06:06:29
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!