]> mop.ddnsfree.com - git repositories - brisk.git/commitdiff
server-side ping management fixed
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Sun, 7 Oct 2012 09:02:36 +0000 (11:02 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Sun, 7 Oct 2012 09:02:36 +0000 (11:02 +0200)
web/Obj/brisk.phh
web/Obj/sac-a-push.phh
web/Obj/user.phh
web/index_wr.php

index 41524d291989e5b2dfa9caffdbd52415b36a5b1f..e7ff7142ecbc78624ecda015ca77e89c2248ba89 100644 (file)
@@ -50,6 +50,8 @@ define('CHAT_ENABLED', TRUE);
 define('SESS_LEN', 13);
 define('STREAM_TIMEOUT', 60);
 /* FIXME: move to sac-a-push .phh */
+/* TIME_RD define the server-side timeout, after half of it a ping request
+   is sent to client, after this time the client is log out */
 define('EXPIRE_TIME_RD', 180);
 define('EXPIRE_TIME_SMAMMA', 360);
 define('EXPIRE_TIME_WAG', 10);
index c9220a1f13ff9f5cb47594e6bf6dbef8fdbee542..fd0368b1074aabbc323ebad29441cce4e79adc66 100644 (file)
@@ -421,13 +421,12 @@ class Sac_a_push {
                         $content = "";
                         $user->stream_main($content, $get, $post, $cookie);
                         printf("[%s] [%d] [%d]\n", $user->name, $user->lacc, $this->curtime);
-                        if (/* $content == "" && */ $user->ping_req == FALSE 
+                        if ($user->ping_req == FALSE
                             && (($this->curtime - $user->lacc) > (EXPIRE_TIME_RD / 2))) {
-                            // $content = $user->stream_keepalive(TRUE);
-                            $content += $user->stream_keepalive(TRUE);
+                            $content .= $user->stream_keepalive(TRUE);
                             $user->ping_req = TRUE;
                         }
-                        if ($content == "" && $user->rd_kalive_is_expired($this->curtime)) {
+                        else if ($content == "" && $user->rd_kalive_is_expired($this->curtime)) {
                             $content = $user->stream_keepalive(FALSE);
                         }
                         if ($content != "") {
index 8beb49bfdd4fe54923ba1c2e1d14858152c4c0d9..a6f1b90c87b854fb52bb86429f37c0ddae32eabe 100644 (file)
@@ -946,11 +946,12 @@ push(\"%s\");
 
 function stream_keepalive($with_ping)
 {
-    return (sprintf("<script id='hs%d' type='text/javascript'><!--
+    $ret =  (sprintf("<script id='hs%d' type='text/javascript'><!--
 push(%s);
 // -->
 </script>", $this->rd_scristp++, ($with_ping ? "\"act_ping();\"" : "null")));
-    
+
+    return ($ret);
 }
 
 static function base_get()
index 6995a18c04c58c64181f3f724fdaa8f5fd63d21a..727f62b265019fa4f79f5661551a373367ca935a 100644 (file)
@@ -197,9 +197,8 @@ function index_wr_main(&$room, $remote_addr, $get, $post, $cookie)
 
     log_wr('POSTSPLIT: '.$argz[0]);
 
-    log_wr($user->step, 'index_wr.php: after get_user()');
-
     if ($argz[0] == 'ping') {
+        log_wr("PING RECEIVED, LACC UPDATED\n");
         $user->lacc = $curtime;
     }
     else if ($argz[0] == 'shutdown') {