gst status object and sess-ion value passed to http_streaming as params
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Wed, 25 Apr 2012 09:09:59 +0000 (11:09 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Wed, 25 Apr 2012 09:15:23 +0000 (11:15 +0200)
web/test-hs-rd.php
web/test-hs.php
web/xynt/xynt-http-streaming.js

index bd4667e..78baf48 100644 (file)
@@ -19,7 +19,12 @@ function mop_flush()
 
 function main()
 {
-    $st = 0;
+    GLOBAL $st;
+
+    if (!isset($st)) {
+        $st = 0;
+    }
+
     $fp = fopen("/tmp/test-hs-rd.log", "a");
     fwrite($fp, "START\n");
     fclose($fp);
@@ -38,9 +43,10 @@ function main()
             // exit();
             sleep(30);
         }
-        printf("<script id='hs%d' type='text/javascript'>
-push(\"$('cont').innerHTML += '%s %d';\");
-</script>", $i, ($first ? "<br/>" : ""), $i);
+
+printf("<script id='hs%d' type='text/javascript'>
+push(\"$('cont').innerHTML += '%s %d'; gst.st = %d;\");
+</script>", $i, ($first ? "<br/>" : ""), $i, $i);
 
         if ($first)
             printf("<!-- %s -->", $s);
index 3ffd263..c09c75c 100644 (file)
@@ -4,14 +4,25 @@
 <script type="text/javascript" src="xynt/xynt-console.js"></script>
 <script type="text/javascript" src="xynt/xynt-http-streaming.js"></script>
 <script type="text/javascript"><!--
-var allmythings="BEGIN";
+var gst = null;
 
 <?php
     if ($action != 'stop') {
 ?>
 window.onload = function () {
     var hs;
-    hs = new http_streaming(window, console);
+    var sess;
+
+    sess = '<?php
+    if (!isset($sess)) {
+        $sess = md5(mt_rand());
+    }
+    printf("%s", $sess);
+?>';
+    
+    createCookie('sess', sess, 24*365,cookiepath);
+    gst = new globst();
+    hs = new http_streaming(window, gst, sess, console);
     // FIXME: with relative path not work!
     hs.start('http://dodo.birds.lan/xynt/test-hs-rd.php');
     // hs.start('test-hs-rd.php');
@@ -20,8 +31,6 @@ window.onload = function () {
     }
 ?>
 
-
-
 window.onkeypress = function () {
     console.log("win kpress");
 }
index 7efb2f5..5a0c615 100644 (file)
@@ -27,14 +27,15 @@ globst.prototype = {
     }
 }
 
-function http_streaming(win, cons)
+function http_streaming(win, gst, sess, cons)
 {
     this.console = cons;
     this.win = win;
+    this.sess = sess;
     this.doc = win.document;
     this.keepalive_old = -1;
     this.keepalive_new = -1;
-    this.gst = new globst();
+    this.gst = gst;
     this.cmdproc = function(com){eval(com);}
 }
 
@@ -42,6 +43,7 @@ http_streaming.prototype = {
     console:           null,
     win:               null,
     doc:               null,
+    sess:              null,
     ifra:              null,
     page:              null,
     watchdog_hdl:      null,
@@ -72,6 +74,9 @@ http_streaming.prototype = {
         this.doc.body.appendChild(this.ifra);
         if (page != null)
             this.page = page;
+        this.page = url_append_args(this.page, "sess", this.sess, "st", this.gst.st);
+        this.log(this.page);
+
         // this.log(this.ifra);
         this.ifra.contentWindow.location.href = this.page;
         this.watchdog_ct  = 0;