-1
\$\begingroup\$

I'm currently using the following MySQL example to make a server side high score table: Unity Server Side high score

The above example allows me to create a top 5 player high score table that sorts itself based on the score amount. However, my knowledge of PHP and MySQL is limited to only that of the above example and I wish to expand upon it.

What I now want to do is create a local score amount (the score the player accumulates during game play) that is updated on my server. At the moment, the server only calls the total scores once, and I want it to be polled so that it updates the moment the player earns some points. And displays this score.

The reason for this, is because my high score, and local score, are going to be displayed on another device. Say your playing my game on a PC but the score is updating and showing you on an iPad (rubbish example, but you get the idea).

Can anyone point me in the right direction as to how I would go about doing this, using the example I've already used?

\$\endgroup\$
0
\$\begingroup\$

You can implement a function that will run as a callback when the player's score changes, this function can open a socket and send the required data to the server. I don't think it is necessary to do this asynchronously since the player's score is usually an integer (4 bytes) so sending it to the server won't be a great deal (along with the bytes of the protocol you are using, if you are using one).

The only case you need to do it in async is when there are lots of people sending data simultaneously and your server doesn't have enough unused connections to accept another incoming request, thus blocking the client (your game).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.