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 ?
|
|
|
|
matheus23
|
 |
«
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.
|
|
|
|
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 
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Gjallar
|
 |
«
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?
|
|
|
|
matheus23
|
 |
«
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  It would definatly work with your webserver  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.
|
|
|
|
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 shi t. 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...
|
|
|
|
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.  Just something like: POST: /store_highscore.php?name=foo&score=bar&otherdataforverifyingthehighscoreisvalid
|
|
|
|
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 ... )
|
|
|
|
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
|
|
|
|
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!
|
|
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  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  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; } |
|
|
|
|
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
|
|
|
|
ra4king
|
 |
«
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 
|
|
|
|
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  ) On desktop, I only know gamejolt but I really believe there are more out there.
|
|
|
|
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
|
|
|
|
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.
|
Lethal Running - a RPG about a deadly game show held in a futuristic dysoptian society.
|
|
|
sproingie
|
 |
«
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.
|
|
|
|
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.
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
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 ^^
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
davidc
|
 |
«
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.
|
|
|
|
Bogdan
Senior Newbie  Projects: 1
|
 |
«
Reply #25 - Posted
2013-04-19 09:39:10 » |
|
What about something like parse.com?
|
|
|
|
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/downloadsWrote 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
|
|
|
|
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.
|
|
|
|
|