From: Leif W <war...@us...> - 2003-10-14 13:54:07
|
I was thinking of how to approach this problem a while back (for the case= of a simple online cardgame) but never came to anything concrete. However, = I did remember playing with some script (it was in Perl but you could use a= ny language) which acts as a server-push, but it only works for Mozilla, not IE, and not tested in Opera or Safari. So, if you want a true client-ser= ver model with bidirectional communication I guess you're best off coding a J= ava applet for the browser, and whatever language specialized server with you= r own protocol. Anyways here's the example code I was using. Also, I was testing on an Apache server and the script would not work unless the filename began wit= h "nph-" which stands for non-parsed headers. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D BEGIN - Perl script =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D #! /usr/bin/perl -w use strict; use CGI qw/:standard :push/; use CGI::Carp 'fatalsToBrowser'; $CGI::POST_MAX =3D 1024 * 1024; # max 1M posts $CGI::DISABLE_UPLOADS =3D 1; # no uploads $| =3D 1; print multipart_init(-boundary=3D>'----here we go!'); foreach (0 .. 4) { print multipart_start(-type=3D>'text/plain'), "The current time is ",scalar(localtime),"\n"; if ($_ < 4) { print multipart_end; } else { print multipart_final; } sleep 1; } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D END - Perl script =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D As you can see, most of the actual server-push code is handled by the CGI Perl Module. So just taking a quick peek inside to show the relevent bit= s of raw HTTP and HTML tricks used, or just using telnet or wget to fetch f= rom the server. Headers: (first three added by Apache, last one added by the script) HTTP/1.0 200 OK Server: Apache/2.0.47 (Unix) mod_ssl/2.0.47 OpenSSL/0.9.7c DAV/2 PHP/4.3.4RC1 Date: Tue, 14 Oct 2003 13:39:48 GMT Content-Type: multipart/x-mixed-replace;boundary=3D"----here we go!" Content: WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY. ------here we go! Content-Type: text/plain The current time is Tue Oct 14 09:39:48 2003 ------here we go! Content-Type: text/plain The current time is Tue Oct 14 09:39:49 2003 ------here we go! Content-Type: text/plain The current time is Tue Oct 14 09:39:50 2003 ------here we go! Content-Type: text/plain The current time is Tue Oct 14 09:39:51 2003 ------here we go! Content-Type: text/plain The current time is Tue Oct 14 09:39:52 2003 ------here we go!-- WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY. ----- Original Message -----=20 From: "Raymond Irving" <xw...@ya...> To: <dyn...@li...> Sent: Monday, October 13, 2003 10:27 AM Subject: Re: [Dynapi-Help] Simple communication questions... > > See below: > > --- Clemens Eisserer <Lin...@we...> wrote: > > Hi again! > > > > I=B4m currently thinking about writing a simple > > JS-Chat, so that the chat doent need to reload > > always when > > new messages recieve. > > The problem is, that the server should connect to > > the client, which is not possible as far as I know, > > this > > means the client has to use possling and aks all x > > seconds the server for new messages. > > > > 1.) Is there no other was to do this than polling? > > Not that I know of > > > 2.) These are the only polling-ideas I had: > > * Blocking soda-rpc function. Blocks till messages > > are on server. (Problem with blocking - no events > > etc?) > > * Non-Blocking soda-rpc function. Returns -1 if > > nothing is there... > > > > Is the blocking version possible, or will it cause > > the application to hand in the poll-loop. This is a > > problem > > in my eyes since JS hasnt support f=FCr Multithreading > > :( > > Using synchronous GET or post will cause the app to > wait until the server returns a response. > > > > Does anybody have better ideas, I=B4m not really happy > > with my stuff.. > > In the future there might be an easier method > > -- > Raymond Irving > > > lg Clemens > > > > PS1: How hard would it be to adopt dynapi to > > knoqueror? (only because it interrests me why so > > many > > examples dont work..) > > PS2: Dynapi is great! > > > > > _________________________________________________________________________= ___ __ > > Zwei Mal Platz 1 mit dem jeweils besten > > Testergebnis! WEB.DE FreeMail > > und WEB.DE Club bei Stiftung Warentest! > > http://f.web.de/?mc=3D021183 > > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: SF.net Giveback > > Program. > > SourceForge.net hosts over 70,000 Open Source > > Projects. > > See the people who have HELPED US provide better > > services: > > Click here: http://sourceforge.net/supporters.php > > _______________________________________________ > > Dynapi-Help mailing list > > Dyn...@li... > > > https://lists.sourceforge.net/lists/listinfo/dynapi-help > > > __________________________________ > Do you Yahoo!? > The New Yahoo! Shopping - with improved product search > http://shopping.yahoo.com > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > SourceForge.net hosts over 70,000 Open Source Projects. > See the people who have HELPED US provide better services: > Click here: http://sourceforge.net/supporters.php > _______________________________________________ > Dynapi-Help mailing list > Dyn...@li... > https://lists.sourceforge.net/lists/listinfo/dynapi-help > > |