This is a clever trick i do to control the ending of a browser load for a page. With this subroutine, i created a javascript and perl web chat engine. As soon as a remote visitor adds text to the chat room, this subroutine completes it's wait pattern which closes the load to the client computer. All that's needed is a simple <body onLoad="refreshChatWindow()"> in the html page and BAM! you have a fully shared text object with any browser. If this is confusing try this, Bob and Jane in chat room. Bob's browser loads the chatyes.gif from your perl script. The perl script pauses to finish the image download until Jane adds text to the chat room. Once Jane hits submit button; Bob's page is reloaded. This low-tech solution has proven to be very effective. Pasteing the entire script would require me making an unrelated custom module of mine portable. But i think the gist of the idea is here in this subroutine.See this subroutine in action at chat.metasphere.net
sub ipImage{ print "Content-type:image/gif\n\n"; $content = "chatyes.gif"; open (FILE,"$content"); while ($line = <FILE>){ print "$line"; }close FILE; for($x=0;$x<30;$x++){ if (-e "webchat/$iplogin.t"){ unlink("webchat/$iplogin.t"); $x=1000; exit; } sleep(1); } }#################################### end ipImage
In reply to A Socket Streamer Subroutine by true
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |