From 2f7ef792e22946a9678f5982a19dacdccd9091eb Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sun, 7 Oct 2012 11:02:36 +0200 Subject: [PATCH] server-side ping management fixed --- web/Obj/brisk.phh | 2 ++ web/Obj/sac-a-push.phh | 7 +++---- web/Obj/user.phh | 5 +++-- web/index_wr.php | 3 +-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 41524d2..e7ff714 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -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); diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index c9220a1..fd0368b 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -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 != "") { diff --git a/web/Obj/user.phh b/web/Obj/user.phh index 8beb49b..a6f1b90 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -946,11 +946,12 @@ push(\"%s\"); function stream_keepalive($with_ping) { - return (sprintf("", $this->rd_scristp++, ($with_ping ? "\"act_ping();\"" : "null"))); - + + return ($ret); } static function base_get() diff --git a/web/index_wr.php b/web/index_wr.php index 6995a18..727f62b 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -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') { -- 2.17.1