Create an interactive website

I want to create an interactive website using aspx and ajax, which, for example, will be able to create a room for chess games, and other players will be able to join.

I have 2 questions:

  • I wonder if you have any ideas how I can do this after one player clicks a button and finishes his move, the other player can make a move.

After the first player finishes his move, I will change the move using the database, but I want to update another playerโ€™s website so that the one who finished his turn turns to the second player?

  1. When someone creates a room and closes their browser, I need this room to be closed. Should I use Session_OnEnd to close the room he opened?

Thanks!

+4
source share
2 answers

I wonder if you know how you can. I do this after one player presses a button and finish the turn, another player will be able to make a move.

There are many ways to do this. If it were me, I would have a table of โ€œmoveโ€ tables or something else, and keep track of who is moving there. Then, on the SetInterval() page, a javascript method that uses the ajax service to search in this table for โ€œmoveโ€ and determine when users enable it.

When someone creates a room and how to close his browser - I need this room to be closed. Should I use Session_OnEnd to close the room it opened?

You can use Session_OnEnd . Alternatively, you can use the ajax method, which checks the moves table to see when the user hasnโ€™t checked for x minutes, and then close the session.

+1
source
  • The easiest way is probably to do a simple heartbeat / poll on each client to make sure that it has not passed yet. Although push / comet has become easier and easier these days.

  • If you are already using the interrogation / heartbeat technique, it would be trivial to close the session after, say, 5 missed heartbeats.

0
source

Source: https://habr.com/ru/post/1312564/


All Articles