4

I've found something very strange and I'm quite amazed, I wonder if someone has found it before or could imagine what's hapenning.

I have an ASP.NET MVC3 chess application. Now I'm developing a lobby for users to join and send match invites to others.

Users on the lobby are tracked through a class that is contained on HttpContext.Application, when a user access to lobby's url is added to the list of users and when he leaves the page an AJAX synchronous call, fired from onUnload event, is made to remove him from the list.

While on the page, a javascript code periodically asks server for the list of current users and updates it on client page.

Now, all of this works quite well, but when I reload the lobby page I'm seeing that the logged user is dissapearing from the list. I've checked the execution and seen that when refreshing the page, the controller that loads the lobby fires before the AJAX call that removes the user, so the controller first try to add the user to the list (but as he's already on it he isn't added) and just later he's removed.

I suposed that when refreshing, the onUnload event would execute and, after it returns, the page will be loaded again... however don't seem to be happening on the expected order.

Any idea/suggestion? Thanks.

Bardo
  • 2,470
  • 2
  • 24
  • 42

0 Answers0