Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: PHP Q

  1. #1
    Join Date
    Dec 2007
    Posts
    2,807
    Tokens
    0

    Latest Awards:

    Default PHP Q

    This should be my last question on PHP. If I have an application which POST's to PHP every 4 seconds is there a way that I can detect when they have stopped POSTing and have hence logged off? So say after 8 seconds they haven't posted anything so have quit the Browser or whatever.

    Thanks in advance,
    FlyDuo.

  2. #2
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    Quote Originally Posted by FlyDuo View Post
    This should be my last question on PHP. If I have an application which POST's to PHP every 4 seconds is there a way that I can detect when they have stopped POSTing and have hence logged off? So say after 8 seconds they haven't posted anything so have quit the Browser or whatever.

    Thanks in advance,
    FlyDuo.
    Mr FlyDuo. I remember you saying that Actionscript PWNT php.

    I'm trying to think of a good way to do this.

    You could run a cron job every 10 seconds to check which users havn't posted in 10 seconds. Or you could do it so the thing that gets posted to, for instance if user A is logged off and user B is still online, the script that user B's browser is posting to could check if user A is still posting, but I wouldn't recommend that.

    I'm thinking a cron job really. Depending on your potential user base really.

  3. #3
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    Stop using the word really, it's really annoying.... really. ^_-

    I came across this issue a few days ago when I started making my collaborative viewing application (watching videos in a group/listening to audio together) but my circumstances are slightly different as I have a 'lobby' leader whom I use as the host.

    Having a lobby leader allows me to use regular calls from his/her browser to check a timestamp of when they last made a post request, if it's higher then 20 seconds then I delete their entry from being in the lobby. Then I use a cron job every 5 minutes to see when lobby leaders have quit, just to clean things up. (Note: This is small scale, so I am not worrying about the extra overheads of using user script calls to check).

    Presuming you don't have someone that's meant to be in with them at all times, probably best to run a cron job every 10 / 20 seconds.

  4. #4
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Do a cronjob, 10 seconds is a bit too much.
    Back for a while.

  5. #5
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    It may be too much, but he is trying to get it as close to real-time as possible. (I presume).

    Plus the resources for running that wouldn't really be noticeable.

  6. #6
    Join Date
    Dec 2007
    Posts
    2,807
    Tokens
    0

    Latest Awards:

    Default

    I know what a cronjob is but I haven't really used them really. I'm just really wondering how to do it really. Could anyone give me any help? It would really help me really.

    Basically every user posts his own username to Online.php and I want to say: If(//user hasnt posted in 10 seconds){
    //Do something with user
    }

  7. #7
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    Quote Originally Posted by Source View Post
    Stop using the word really, it's really annoying.... really. ^_-
    You really want me to stop using really ey?

    Quote Originally Posted by FlyDuo View Post
    I know what a cronjob is but I haven't really used them really. I'm just really wondering how to do it really. Could anyone give me any help? It would really help me really.

    Basically every user posts his own username to Online.php and I want to say: If(//user hasnt posted in 10 seconds){
    //Do something with user
    }
    I havn't used a cron job in a few years, but I believe you just put in a little bit of code for it to run, which includes the online.php page, and it runs it.

  8. #8
    Join Date
    Dec 2007
    Posts
    2,807
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by BoyBetterKnow View Post
    You really want me to stop using really ey?



    I havn't used a cron job in a few years, but I believe you just put in a little bit of code for it to run, which includes the online.php page, and it runs it.
    I've used cron jobs in the past for my Flash stuff but they've been more of a C&P job, I'm not sure how to create it myself.

  9. #9
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    If you're using mysql, just slap their name into an online table with the time they last refreshed and check with a simple WHERE `time` > '192382' or something.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  10. #10
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    Quote Originally Posted by Jewish Bear View Post
    If you're using mysql, just slap their name into an online table with the time they last refreshed and check with a simple WHERE `time` > '192382' or something.
    Yeh. To elaborate on what Jew Bear said, have a table called online and have the fields: userid, time.

    Then you will have all your online users in there, and then remove the record if it's not online or whatever. This is opposed to some people who would have the online field in the users table which is not a good idea because the users table will have more to search from.

Page 1 of 3 123 LastLast

Posting Permissions

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