From: <ad...@xe...> - 2003-02-08 16:42:26
|
Derek wrote: > Thanks Kragen! Sorry for the tardiness in responding, it's gotten kinda > busy round here. Whew, I think we all know what that feels like nowadays. > 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.) First off, there's no KNN anymore. We should get modpubsub.com up and running soon, to serve as the *new* KN Network. (Yes, with a weblog, too. Joyce just loves it when I volunteer her for things. :) Fyi, I run a local copy of mod_pubsub's kn_apps on http://pubsub.knownow.com/beta/kn_apps/ A lot of the apps are undocumented or broken, but that's just the way it is. They're all on my "to do" list to fix. Anyway, thanks for the PHP bits below. I'm in the middle of trying to build a new Python Microserver, but PHP connectivity is high on my list of things to work on, too... ;) Adam The rest of Derek's message: > 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 ... |