Find the answer to your Linux question:
Results 1 to 6 of 6
Hi there! I am developing a game one against one, using PHP and MySql and I do not know how to manage this scenario: Let's say that the browser of ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Nov 2009
    Posts
    104

    timeout function on server


    Hi there!

    I am developing a game one against one, using PHP and MySql and I do not know how to manage this scenario:

    Let's say that the browser of one user crashes (a power cut), so JavaScript is not able to tell the Server this user is no longer working.

    The second user is waiting for the first user to move a card.

    How can tell the Server that the first user is no longer available? How can I handle this with session timeouts in PHP?

    My purpose is to execute a function on PHP if a specific time has passed without no activity. This function will update the database so the second user is aware of the first user's crash.

    Thank you very much!

  2. #2
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    Simply have each users game send a request to the other, something like a keepalive request. Once that request isn't answered you will know the other player is no longer connected.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  3. #3
    Linux Newbie
    Join Date
    Nov 2009
    Posts
    104
    Hi Lazydog! Thanks a lot for reply. You mean the keepalive request should be first inserted into the database mysql?? So the second user can read it from the database.

    Because I do not know how to send any information between two PHP session users without using a database.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    Not what I was thinking at all. These games have to talk to one another in order for them to work so you should be able to place a call somewhere in the code that makes a request to the other machine. If it doesn't answer then it should be considered off-line.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  6. #5
    Linux Newbie
    Join Date
    Nov 2009
    Posts
    104
    In PHP I do not how one user (session) can talk to another user (session) directly. To do this, the only thing that I know is to communicate these two users using a database, Mysql in this case.

    Do you know another way to communicate between two users?

    Thank you very much

  7. #6
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    Nope, sorry. I am not a programmer.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

Posting Permissions

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