From: Derek R. <nn...@ya...> - 2003-01-29 17:46:42
|
Thanks Kragen! Sorry for the tardiness in responding, it's gotten kinda busy round here. I forwarded your comments on server-push v. client-pull to the back-end architecting (gahh, when did 'architect' become a verb?) folks at Ludicorp (vide., <http://gameneverending.com/>), it was exactly the sort of information people will most need to know when deciding what technology to base their massively multiplayer online game (for example) on. And so why aren't such figures published front-and-center on the KNN site?? (Not-so-subtle nudge-nudge for KnowNow employees on the list.) Okay, I dug up the PHP bits, it's so simple it hurts -- just gotta watch out not to rely on ob_implicit_flush(), apparently it's still unstable so use an explicit flush() instead. Some sample code (wch. might not survive Yahoo-mail, they're getting testy abt. inline script stuff), e.g.: <?php function msleep($msec){ $start = gettimeofday(); $usec = $msec*1000; do { $stop = gettimeofday(); $timePassed = 1000000 * ($stop['sec'] - $start['sec'])+ $stop['usec'] - $start['usec']; } while ($timePassed < $usec); } function send($msg) { $pre = "<script>parent.msg('"; // start JS call to parent $post = "')</script> "; // wrap-up the JS call echo str_repeat(" ", 300) . "\n"; // MSIE caching fix echo "$pre $msg $post" ; // buffer the message flush(); // send the packet } // set_time_limit(5) ; // optional 5 sec. timeout (default = 30 secs) $z = 10; while ($z>0) { msleep(1000); // Sleep 1 sec. send("<h1>".$z--." ... </h1>"); } msleep(1200); send("<h1>... shooka-pata-tata, hey!</h1>") ; ?> While the client page'd look something like -- <head> <script> function msg(content) { status = " "; // suppress URL display in status bar document.getElementById('display').innerHTML = content ; } </script> </head> <body> <div id="display"></div> <iframe style='display:none' src="pusher.php" name="pushlet"> </body> So I guess you'd just round-robin through the currently connected client IP addresses any time there's something to send 'em, and like that ... D. __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com |