Hi all!
I am working on a turn based web game in PHP5.
This is pretty simple game, a kind of board game: two people join a "session" and they play until one of them wins.
My problem in nutshell:
User A and User B play a game.
User A finished his turn
- Request will be sent to the server to perform necessary operations.
- Now it is time for User B to move..
But how could I notify User B about this?
I mean, now the server has to communicate with the other user, the one that is inactive, not the one that initiated the request.
I know that this could be implemented using some kind of periodic AJAX call that checks whether the opponent finished his turn etc, but such a thing generates a huge number of requests.
Isn't there a better way to solve this?
I'm thinking of something like this:
- User A's turn ends
- Server saves his score
- Server contacts User B
- User B's turn gets started.
Is this possible using PHP and comet-style requests somehow? Or is there a better way to do this?
Any help would be appreciated!
Thanks in advance!