SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    web-based app: how to trigger popup on someone else's computer?

    I have a web-based app where all subscribers are logged in to the site. When Person A presses a button to notify Person B that someone is here to see him, Person B gets a popup on his screen notifying that some is there. (like instant messaging)

    How can you program a popup screen to display on a remote user's screen with a message written by Person A? (Both are logged in to the system).

    Would you just poll every 15 seconds? That would create a lot of unnecessary network traffic.

    Any ideas?

    Many thanks!

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You will have to poll, there's no other way of doing it.

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    polll is like:
    <meta http-equiv="refresh" content="60">

    would poll every minute, right?

    Now if I find a trigger, I would somehow invoke a javascript popup , right?

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When I say poll, I mean "check the server for updates". You'll have to design how and when that happens. I'd be tempted to use ajax, as refreshing a users page every x seconds may be unacceptable, if the user is working on something on that page or reading it.

    I'd do it like this:
    - user logs in to server - some kind of userlist is updated with his status.
    - on the "client" page, the userlist is a div which displays users and their status. Every x seconds, send an ajax request to server to retrieve the new userlist, and display its contents.

    That way there's no page refreshes. Your system's design might not care about refreshes though, so you can get away with meta refresh (if the userlist is its own page and displayed in an iframe, or something similar).

  5. #5
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    jimfraser - many thanks for your input

  6. #6
    SitePoint Guru
    Join Date
    Jun 2006
    Posts
    638
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Depending on your traffic, you might have to use sockets.
    They are a bit more work, but they are "instant".

    If you have to many users online, you can't really make everyone do requests to your server every few seconds, since that will cause to much server load.

    Plus, will your second user (one that sent the request) wait 15 seconds for the first to get the page, and another 15 for the reply?

  7. #7
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, I am thinking just php mail() and just depend on worker B having email client up - that is as instant as you can get assuming email server is fast, without going to ajax calls.

    thanks guys

  8. #8
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no need to refresh. You can setup a listener script in AJAX, which will check for this message every 5-10 mins or so. Once encountered a message, it will just popup the message using alert();
    Last edited by Giga Promoters; Mar 6, 2008 at 23:41.
    Giga Promoters offers wide range of Web Development services.
    We specialize in CakePHP and jQuery.

  9. #9
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    giga - can you give some links to ajax listeners or an example?

    thanks.


Bookmarks

Posting Permissions

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