Leaderboards Without a server?

Started by
19 comments, last by Rutin 6 years, 8 months ago

From what I'm gathering I can just have it pulled from the website and mirrored/pulled into the game when you click the leaderboard option? If so I'll just go that route.

That leads me into my next question- would a website be able to auto sort high scores that are submitted and update it daily? Is it much more feasible  to have it update weekly?

 

3 hours ago, h8CplusplusGuru said:

You cant get a server because of money. If anyone buys your game you'll have money. Why not host your own server on one of your own computers? It's not as if you expect to have crazy traffic, do you? Do you Apache? Maybe you should. 

This may sound like a dumb question but whats Apache? 

Advertisement

Apache is a web sever that manages TCP connections for HTTP communication.  Apache delegates the TCP connection to another script or process, which then processes the request and prepares an appropriate HTTP response with data.  With the appropriate accompanying apache2 module, you can use PHP, Python, or even Perl.  This is the easiest approach.

Another alternative is to write a program that listens to TCP connections on port 80, and handle the HTTP request/response yourself.

The idea with either approach is to handle the two major functions of a leader board:

  • Fetch the top ranking scores of all time
  • Add a high score entry

 

8 minutes ago, fastcall22 said:

Apache is a web sever that manages TCP connections for HTTP communication.  Apache delegates the TCP connection to another script or process, which then processes the request and prepares an appropriate HTTP response with data.  With the appropriate accompanying apache2 module, you can use PHP, Python, or even Perl.  This is the easiest approach.

Another alternative is to write a program that listens to TCP connections on port 80, and handle the HTTP request/response yourself.

The idea with either approach is to handle the two major functions of a leader board:

  • Fetch the top ranking scores of all time
  • Add a high score entry

 

So would it be easier to use Apache as a go between or as the overall host for the site and leaderboard database? 

Or am i missing the point completely?

12 minutes ago, Aaric90 said:

So would it be easier to use Apache as a go between or as the overall host for the site and leaderboard database? 

Or am i missing the point completely?

I'm not sure if you're understanding the options.

1. Host the web server on your own computer using wamp which installs Apache, PHP, mySQL to run on Windows. Then program your client to talk to the web server by passing data to your PHP scripts that pulls data off the database and sends back the information to the client in a read only format. For leader-board sorting, you can sort data with PHP once pulled from the database and read it in any order you need, or send all leader-board data and sort it through the client. (If you're going to go through all this just make the server itself for the game on your computer, no point in doing web only - then once you have enough funds you can move the database and server to a dedicated host very easily!)

2. Pay for cheap shared-hosting like dreamhost, which has PHP and mySQL. Host your scripts on the web host, and access your database through them. You can use curl from what I remember to send and receive information as needed.

https://curl.haxx.se/

Programmer and 3D Artist

apache allows you to turn your favorite computer into a webserver. From there you can do anything web related, on your own computer, having clients connect directly to your computer.

I'm probably not understanding my options; and I hope i am now.

But to make sure I am this is how it SHOULD be set up. 

Client connects to website, website connects to Database submitting Longin/account information with high score data. . Database stores it and sorts it. At a set interval of time Database should send the information to update on the website so the Client can see the information on website and in the game?

And I will look into getting a tower and converting it to a database and one to convert into a webserver(to save on domain hosting costs down the road?). 

Suggestion...

1. Distribute your software (game) and require that they register with your server to end up on the leaderboard. So the client sends a POST message with their e-mail in the message. The server responds with a signed sha256 hash of that e-mail. From that point on that signed hash identifies the player and is sent every single time the player needs to identify itself to the server. The signed hash and email go into a database on the server.

2. When a player's game is complete, it sends the same sha256 hash to the server with the relevant data (wins, losses, who played etc) in a POST message. That data goes into the database using the hash that identifies the player as a key.

3. When a player wants to see the leaderboard, they send a GET message to the server and a list of player statistics is returned (use e-mail or partial e-mail as a key with stastics as the value). The statistics are alll stored in a database so whenever the server recieves the GET message it just has to do a query.

^The problem will all of that is that it is certainly possible for a player to impersonate another player to the server or for a player impersonate the server to a player and cause all kinds of bad things to happen. You would need to use some kind scheme with public/private key encryption to prevent that. Ideally you would want a server to host the game...so the server is adding the statistics, not the client which you really have no control of.

No matter what you do I would not allow a direct sql connection from the client (player) to the server. Have a webapp to the inserting and querying and act as a shield.

For this kind of thing it's worth looking at "serverless" solutions with on-demand pricing.

For example, via AWS (where I happen to work, BTW, but this isn't an official recommendation) you could setup a Lambda to handle the request from the device, and use that to update the database. That gives you the same client<->database isolation that a server does, but unlike a server, you'd only be billed for actual invocations of the Lambda (and there's a decent number of free invocations for new AWS accounts).

You should also look at Google's Firebase which offers the same general functionality under the name "Cloud Functions".

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

2 hours ago, Aaric90 said:

Client connects to website, website connects to Database submitting Longin/account information with high score data. . Database stores it and sorts it. At a set interval of time Database should send the information to update on the website so the Client can see the information on website and in the game?

Close; that last part is reversed.  The game website should either query the database directly or consume the API that your game will use, and render the leaderboard on the fly.
 

2 hours ago, Aaric90 said:

And I will look into getting a tower and converting it to a database and one to convert into a webserver(to save on domain hosting costs down the road?). 

The game website, the database, and the highscore API need not be on different servers.  Apache2, as well as other webservers, can be configured to direct requests to separate processes/scripts depending on the subdomain(s) used in the requests’ `Host` header.  Then, you can configure your domain to point all the subdomains to the correct servers.

2 hours ago, Aaric90 said:

I'm probably not understanding my options; and I hope i am now.

But to make sure I am this is how it SHOULD be set up. 

Client connects to website, website connects to Database submitting Longin/account information with high score data. . Database stores it and sorts it. At a set interval of time Database should send the information to update on the website so the Client can see the information on website and in the game?

And I will look into getting a tower and converting it to a database and one to convert into a webserver(to save on domain hosting costs down the road?). 

Can you please let me know what options you've tried from the above posts? Did you get a chance to look at https://curl.haxx.se/ for the Client -> Web Server -> Database and back? Are you going to host the web server on your own computer, or use a 3rd party?

There are only two sources here you need to worry about:

1. Client (Running on the users machine)

2. Web Server (This hosts all your PHP scripts to verify, and other scripts as you need, plus the Database)

I would strongly suggest you try out the suggestion I posted prior, or consider what swiftcoder posted.

If you're using your own computer use WAMP (If on Windows) to install all the tools you need, setup your Database, and program your scripts to work with the client, and database. If you're running into problems we can help a bit more, but I really cannot add anymore nor can anyone else because you have two options in your scenario. Host the web server yourself, or pay for cheap hosting that can access your script file, and host your database. At most this would take someone 30 minutes to setup if you know how to do all the scripting, and database creation. The more technical part would be with how your client talks to the web server, and what option you use to accomplish this task, such as https://curl.haxx.se/

Programmer and 3D Artist

This topic is closed to new replies.

Advertisement