Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: GUI with HTTP::Daemon

by bbfu (Curate)
on Dec 19, 2004 at 20:37 UTC ( #416048=note: print w/replies, xml ) Need Help??


in reply to GUI with HTTP::Daemon

And finally, a small quest for Perl wisdom: what's a portable way to find out if the user has left the "site" or closed the browser window? So far, I've told users of these little applications to hit ^C when done, but that's not pretty.

Idle musings... Doesn't pretty much every browser now support Connection: Keep-Alive? Is there a way to consistently induce this behavior and, if so, couldn't you then just watch for the socket closing in the HTTP::Daemon server and assume that means the window was closed?

bbfu
Black flowers blossom
Fearless on my breath

Replies are listed 'Best First'.
Re^2: GUI with HTTP::Daemon
by Juerd (Abbot) on Dec 19, 2004 at 21:14 UTC

    Doesn't pretty much every browser now support Connection: Keep-Alive?

    Yes, but the browser usually closes the socket when it's done rendering a page, IIRC.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      Ah, that may well be the case. I thought that the browser kept it open until the site was left or the window closed but I can certainly see how it might make sense to close it when done rendering. Oh well.

      Hrm. If the browser does indeed close the connection after rendering the page, what about opening your own connection manually via javascript? Are javascript sockets automatically closed when the page is closed / unloaded? I would think they would be, so that means you could perhaps simply open a connection to a "keep alive" server, stick it in a globally scoped variable, and then just forget about it. I haven't done enough with javascript sockets to know if this is feasible. Alternatively, you could perhaps use a hidden frame that never finishes rendering to accomplish the same effect.

      bbfu
      Black flowers blossom
      Fearless on my breath

        With the growing ubiquity of the XMLHttpRequest object in browsers now, you could have the app ping the server with requests every so often and have the server watch for this heartbeat to die.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://416048]
help
Chatterbox?
Discipulus is going mad with the new win10 client.. tried mv Cortana /dev/null but no succes
[Corion]: Ouch - another pretrained set is available, using images from IMDB and Wikipedia. So I expect interesting results for non-PR images where people are pictured that are not made up
[Corion]: Discipulus: Yeah, from my investigations, you can somewhat silence+disable Cortana, but some services of it remain always running unfortunately. What a waste of resources :-/
[Corion]: I hope you had a good weekend still ;)
choroba had a workshop with the band
[choroba]: which counts as a good weekend
[Discipulus]: yes, (at least until Sun afternoon...): Saturday we got splendid birthday party in a park: lot of eat, drink and children amusement: bag running, magnetic fishing, rope and that big pot full of candies to smash with a club

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2017-09-25 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (277 votes). Check out past polls.

    Notices?