dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Game logged in

  1. #1
    Join Date
    Oct 2010
    Posts
    1

    Game logged in

    I'm creating a game where people can login using their username and password, it's runs via a php script(I think this is the best way). when logged in they can create a new "room" or join an existing one, the problem is how can make the room(other players in the room) know that someone disconnected, if they properly log out its easy but what if their internet connection went down during a game how can i let the room know that he/she is not in the room any more. I could of course send a query to the server every second the user is logged in and when the server doesn't get any queries no more the user is logged out, but this would really slow down the server. so is there any other solution for this?

  2. #2
    Join Date
    Oct 2010
    Posts
    12

    Re: Game logged in

    This is not a helpful post but from what I can tell, you will want to set each client side software to set an "im alive" variable every x time on the server. Think sending a small packet of info.

    A timer will look down the DB on a separate thread and routinely check for last logon confirmed time to current. if more than Y has passed it will pass a global channel "Person ABC is no longer in the room".

    Lots of variations of this could also work. Sorry I cannot provide any sort of code snippets. I've never even contemplated this so have no old code snippets related. I'd also point out this is C#and not PHP, but I'm guessing you wanted a general idea and was not language dependant.

    Hope this helps, but I doubt it will!

  3. #3
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Game logged in

    Quote Originally Posted by urisk View Post
    I could of course send a query to the server every second the user is logged in and when the server doesn't get any queries no more the user is logged out, but this would really slow down the server. so is there any other solution for this?
    No, it wouldn't. It is called a ping, and this is how you do it. There is no magical way to know that someone lost their connection. You send a minimal amount of data every so often, it is also called a 'heartbeat'.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)