Re[2]: server's initiative

Anne,

AvK> http://labs.opera.com/news/2006/09/01/

Am i understand right, that it's supposed to use one
server-side script to generate primary html-document
and server's event after document ?
I.e. something like the following,
where '...' means generation of html-document.

#!/usr/bin/python
import sys
import time
...
print "Content-Type: application/x-dom-event-stream\n\n"
while True:
    print "Event: server-time"
    print "data: %f\n" % (time.time(),)
    sys.stdout.flush()
    time.sleep(3)

If all, what i have said, is correct,
then it's easier to extract single string during
generation of document, i.e.

print "<head> <meta name=register content=785> </head>"

that browser itself make all,
than to write difficalt (for non-programmers) script
and put it instead of mentioned single line.

print "<style type="text/css">
       document.getElementsByTagName("event-source")[0]
       .addEventListener("server-time", eventHandler, false);

       function eventHandler(event) {
         alert(event.data);
       }
       </style>
"

Right ?



Dmitry Turin
HTML6     (6. 5.3)  http://html60.euro.ru
SQL5      (5.11.0)  http://sql50.euro.ru
Unicode7  (7. 2.1)  http://unicode70.euro.ru
Computer2 (2. 0.2)  http://computer20.euro.ru

Received on Thursday, 7 February 2008 11:08:39 UTC