I want to create an interactive website using aspx and ajax, that there will be an option to create chess game room for example and other players will be able to join.
I have 2 Questions:
- I wonder if you have any idea how can I make that after one player clicks on a button and finish his turn, the other player will be able to do a move.
After the first player finish his turn I will change the turn by using the database, but the point is how can I refresh the other player’s site so when the other one finish his turn, the turn will come to the second player?
- When someone creates a room and than close his browser – I need that room to be closed.
Shall I use the Session_OnEnd to close the room he opened?
Thanks!
There are a lot of ways you can do this. If it was me I would have a “moves” database table or something and track whos move it is in there. Then on the page have
SetInterval()javascript method that uses an ajax service to look in that “moves” table and determine when it is the users turn.You can use
Session_OnEnd. As an alternative you could use the ajax method that checks themovestable to see when a user hasn’t checked in x minutes, then close their session.