Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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  
  Storing Highscore... where ?  (Read 4561 times)
0 Members and 1 Guest are viewing this topic.
Offline Cero
« Posted 2012-11-06 18:46:09 »

So say I want to implement a Highscore feature in my game, which should work globally on the internet, I mean what would be the point otherwise... :0

is there any way or place I can easily do this, without renting a server just for highscores ?

Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #1 - Posted 2012-11-06 18:46:51 »

is there any way or place I can easily do this, without renting a server just for highscores ?

Nope.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Cero
« Reply #2 - Posted 2012-11-06 18:50:03 »

I do have a webserver/space for our website...
if I create a table on the database on there, and connect from the game... could work
of course my fears are: bandwidth and storing my password somewhere in my game  persecutioncomplex

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Gjallar

JGO Coder


Medals: 13
Projects: 1


Follower of Nurgle


« Reply #3 - Posted 2012-11-06 18:51:38 »

Couldn't you just use an old laptop that you constantly plug in somwhere at home as a server?
Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #4 - Posted 2012-11-06 18:51:48 »

I do have a webserver/space for our website...
if I create a table on the database on there, and connect from the game... could work
of course fear are: bandwidth and storing my password somewhere in my game  persecutioncomplex

It would definatly work with your webserver Wink
And yeah, you'd need to create a table or something like that.

Bandwidth shouldn't be a problem,
and I'm not sure what you're talking about with the password... But yeah, security is always a problem.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Cero
« Reply #5 - Posted 2012-11-06 19:17:09 »

Couldn't you just use an old laptop that you constantly plug in somwhere at home as a server?
Well you can't just host a server from your home; you gotta call your ISP and setup shit.

and I'm not sure what you're talking about with the password... But yeah, security is always a problem.
To connect to the database in the first place you gotta log in, hence my game code has to log in, which means the password for the database would be hardcoded in the game...

Offline Regenuluz
« Reply #6 - Posted 2012-11-06 19:42:33 »

Or you could make an API that your game calls with some game data, then that data gets verified and placed in your db. No need for storing any passwords. Smiley

Just something like:

POST: /store_highscore.php?name=foo&score=bar&otherdataforverifyingthehighscoreisvalid

Offline deathpat
« Reply #7 - Posted 2012-11-06 19:45:54 »

Well you can't just host a server from your home; you gotta call your ISP and setup shit.
normally you can, it is just a matter of configuration of your home network ( port forwarding if you are behind a router ) ... except if your ISP have put some limitations. In Frence the only limit is the bandwidth.

But anyway if you already have a website hosted somewhere, it's better to use this hosting I think.

To connect to the database in the first place you gotta log in, hence my game code has to log in, which means the password for the database would be hardcoded in the game...

The idea would be that your game would send an HTTP request to the webserver ( sending all the data you want to store ) and the webserver will act as usual, connecting to the database, store the data and so on. Your database password will then not be exposed.
... then the only problem remaining is how to fight cheating ( anyone could send an HTTP request to store fake highscores ... )

work in progress : D A E D A L U S
Offline Cero
« Reply #8 - Posted 2012-11-06 20:14:44 »

cheating and sql injection would be things to consider

although it seems that even AAA game highscores have cheaters so...
in theory I would use POST to submit the data and a special key to prove that its genuine...

in practice I have no idea how to do this in Java... the most I ever did was downloading a file

Offline Danny02
« Reply #9 - Posted 2012-11-06 20:22:21 »

you could try google app engine.
It's a free web server, so you could everything u want.
Of course they have restrictions for the free use, like only so much bandwith per month etc., but I guess this should be enough for a small game.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline deathpat
« Reply #10 - Posted 2012-11-06 21:00:27 »

cheating and sql injection would be think to consider
sql injection is to be considered for any HTTP request Smiley

although it seems that even AAA game highscores have cheaters so...
in theory I would use POST to submit the data and a special key to prove that its genuine...

in practice I have no idea how to do this in Java... the most I ever did was downloading a file

If you find a solution for the special key, please tell me Smiley Because as java can be easily decompiled, I can't see how to generate safely such a special key in the game.

otherwise, sending an HTTP request is as simple as that :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
   public static String sendHttpRequest(String strUrl, String data, boolean needResponse) {
      String res = null;

      try {
         URL url = new URL(strUrl);
         URLConnection urlConnection = url.openConnection();
         urlConnection.setDoOutput(true);
          OutputStreamWriter wr = new OutputStreamWriter(urlConnection.getOutputStream());
          wr.write(data);
          wr.flush();
          BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
         
          if (needResponse) {
              StringBuilder sb = new StringBuilder();
              String line = null;
              while ((line = reader.readLine()) != null) {
                 if (sb.length() > 0) {
                    sb.append("\n");
                 }
                  sb.append(line);
              }
              res = sb.toString();
          }
      } catch (Exception e) {
         e.printStackTrace();
      }
        return res;
   }


where data is in the form key=value&key2=value2 ...

keys and values have to be encoded :

1  
2  
3  
4  
5  
6  
7  
8  
9  
   public static String encodeParam(String paramName, Object value) {
      String res = "";
      try {
         res = URLEncoder.encode(paramName, "UTF-8") + "=" + URLEncoder.encode(String.valueOf(value), "UTF-8");
      } catch (UnsupportedEncodingException e) {
         throw new RuntimeException("can't encode parameter : "+paramName, e);
      }
      return res;
   }

work in progress : D A E D A L U S
Offline Cero
« Reply #11 - Posted 2012-11-06 21:44:32 »

otherwise, sending an HTTP request is as simple as that
Ah, works beautifully

If you find a solution for the special key, please tell me  Because as java can be easily decompiled, I can't see how to generate safely such a special key in the game.
I'm quite interested in security aspects, but right now for this problem, I think it would be overkill and waste of time to invest into security.

Well at least as far as cheating goes... SQL injection could really screw my database up

Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #12 - Posted 2012-11-07 00:25:48 »

How about www.gamejolt.com ?

Either way, I do my own hosting and I've written my own server in Java that takes and stores high scores. I also did not need to contact my ISP for anything, I just used DynDNS to have a constant domain to my ever-changing IP address and it works beautifully Smiley

Offline ReBirth
« Reply #13 - Posted 2012-11-07 04:03:55 »

On android you can have Swarm or Scoreloop (don't use OpenFeint, it's sent from hell Angry )

On desktop, I only know gamejolt but I really believe there are more out there.

Offline meingrosserfreundjo

Senior Newbie





« Reply #14 - Posted 2012-11-07 15:04:04 »

Create a SQL User.
GRANT that User INSERT on your Highscore-Table. Maybe UPDATE if you just want one entry per user.

Use a System like Minecraft -> Username and Password for Game needed (Maybe only at the point where the Highscore gets sent).

When the Highscore is to be submitted -> send score along with username and pw (and other data to be stored) To a php script. If valid credentials -> store in Highscore DB, if not -> give client signal to explode.

SQL Injections and cheating on Client-side are things that have to be considered always and everywhere.

PS.: SQL Injections can be dealt with when you escape characters per default and perform validity checks on the values. If a score consists of anything else than numbers its rubbish for example (depends on your game of course). But how you could deal with cheating -> no idea
Offline 65K
« Reply #15 - Posted 2012-11-07 18:16:26 »

Never build SQL statements from user input but use statement objects and injections are not an issue.

Offline sproingie

JGO Kernel


Medals: 202



« Reply #16 - Posted 2012-11-07 21:00:50 »

Just use GAE.  It's free, and there's no SQL involved in the database.

There's also nothing you can do to stop determined cheaters.  Consider whether you really want a global scoreboard at all in light of that.
Offline Agro
« Reply #17 - Posted 2012-11-08 00:07:28 »

It's not that hard to port forward... If you use AT&T you can do it all by yourself. Other than that, i dont know. And it would be better for something like high scores to be stored in a databased and accessed through a PHP script over HTTP, honestly.

Offline Cero
« Reply #18 - Posted 2012-11-08 00:36:02 »

And it would be better for something like high scores to be stored in a databased and accessed through a PHP script over HTTP, honestly.

I ended up doing that. Code is already done, the applet version of Black Nebula has it implemented.
But the libgdx input thingy is... a little clunky on non android systems =P
doesnt even work in fullscreen since its this dialog thing

Offline Agro
« Reply #19 - Posted 2012-11-08 00:38:50 »

Well I think it depends on what kind of game you're making. If its something like Call of Duty, probably shouldn't use the method I described above. If its a fairly static game, PHP would be legible. I guess its from what kind of perspective you see it from.

Offline Regenuluz
« Reply #20 - Posted 2012-11-08 07:30:33 »

Well I think it depends on what kind of game you're making. If its something like Call of Duty, probably shouldn't use the method I described above. If its a fairly static game, PHP would be legible. I guess its from what kind of perspective you see it from.

Eh? What would be the difference in using php for server backend for a dynamic game or a static? Seeing as php is a "full fledged" programming language ^^
Offline Cero
« Reply #21 - Posted 2013-04-18 17:22:49 »

you could try google app engine.
It's a free web server, so you could everything u want.

Just use GAE.  It's free, and there's no SQL involved in the database.

Yeah I took a look... its ginormous... I don't know which jars I would need to deploy yet but its > 100mb all in all, and every jar > 10mb
and I want to use this on android as well... for a simple highscore feature, that really overkill

Offline ReBirth
« Reply #22 - Posted 2013-04-19 02:05:40 »

If Javascript is not problem for you, I think you can setup a simple database with nodejs server in less than half day. The server just only need to do query and send json back as response through request.

Offline Danny02
« Reply #23 - Posted 2013-04-19 06:49:45 »

you could try google app engine.
It's a free web server, so you could everything u want.

Just use GAE.  It's free, and there's no SQL involved in the database.

Yeah I took a look... its ginormous... I don't know which jars I would need to deploy yet but its > 100mb all in all, and every jar > 10mb
and I want to use this on android as well... for a simple highscore feature, that really overkill

I think you got something wrong, there arn't any libs/jars you need to add to your client/game. You just create a simple webservice which you can access with a simple http post for example.
Offline davidc

Senior Member


Medals: 5
Projects: 2



« Reply #24 - Posted 2013-04-19 09:37:50 »

As mentioned before, it isn't too hard to roll your own high score service that uses POST to register scores and GET to retrieve them. I've set one up for my own games, I already had a hosting package that I'm using for other things that provides PHP and MySQL. Creating some simple scripts to register and retrieve high scores was a piece of cake. Some more details here.


It works well enough, and doesn't require any permissions for an applet deployed on the same site to access it. So far I haven't given any consideration to security, but I figure the 2 or 3 people that ever play the games have got better things to do than try hacking in their own scores.

If I get time and there is demand for it, I'll publish all the code and database structure. There isn't a lot too it. Apart from the database and scripts, there's a bit of fancy URL rewriting to make it work as a nice RESTful web service and a java client for issuing all the relevant commands.

Offline Bogdan

Senior Newbie


Projects: 1



« Reply #25 - Posted 2013-04-19 09:39:10 »

What about something like parse.com?
Offline Cero
« Reply #26 - Posted 2013-04-19 16:44:59 »

you could try google app engine.
It's a free web server, so you could everything u want.

Just use GAE.  It's free, and there's no SQL involved in the database.

Yeah I took a look... its ginormous... I don't know which jars I would need to deploy yet but its > 100mb all in all, and every jar > 10mb
and I want to use this on android as well... for a simple highscore feature, that really overkill

I think you got something wrong, there arn't any libs/jars you need to add to your client/game. You just create a simple webservice which you can access with a simple http post for example.

oh yeah ?
I mean: https://developers.google.com/appengine/downloads


Wrote my own now, but if google works, I'll check it out again

What about something like parse.com?
Mh, not sure it does what I need for free... in that case I might as well use my own server

Offline Danny02
« Reply #27 - Posted 2013-04-19 19:10:12 »


GAE is a special web-server, these downloads are as noted the SDK(which holds for example a little test server which you can start on the local-host to test stuff).

All the libs which are included are used on the server, nothing of this sdk is needed for the client.
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.

CopyableCougar4 (8 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
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!