Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm building a website using ASP.NET. It's a game which I connect two users randomly to play with each other.

What I need to do is when one of these two players logs out or has been inactive for a certain time, I finish the game and send the other player to some page to tell him or her the game is over.

My problem is I can't figure out how to track the user status every while. I know that ASP.NET has (LastActivityDate), but how can I check this value repeatedly every 30 seconds for example?
Posted

Use AJAX. Write a simple javascript function to make an AJAX call to a handler on your web app, sending some user id. In that handler use the id to mark user active and check the opponents status.
 
Share this answer
 
Comments
RubaRoro 14-May-12 9:58am    
can you give me a little help with implementing this ?
I'm so new to AJAX and javascript
sjelen 15-May-12 7:18am    
I can not help you with implementation without knowing much more about your app.
If you want this game to look and work good, you really have to learn javascript. Get yourself familiar with some javaScript framework, like jQuery - it will make things easier for you.
RubaRoro 15-May-12 10:51am    
I've tried to put an updatepanel and timer in it, and in the timer_tick event I did some checking .
Is it a good way?
sjelen 15-May-12 12:44pm    
It's probably the easiest way to start, if you are not familiar with javaScript.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900