projects
/
brisk.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
64168bc
)
app level keepalive (new ping message) added
author
Matteo Nastasi
<nastasi@alternativeoutput.it>
Sun, 5 Aug 2012 05:37:22 +0000
(07:37 +0200)
committer
Matteo Nastasi
<nastasi@alternativeoutput.it>
Sun, 5 Aug 2012 05:37:22 +0000
(07:37 +0200)
web/Obj/sac-a-push.phh
patch
|
blob
|
history
web/Obj/user.phh
patch
|
blob
|
history
web/briskin5/index_wr.php
patch
|
blob
|
history
web/commons.js
patch
|
blob
|
history
web/index_wr.php
patch
|
blob
|
history
diff --git
a/web/Obj/sac-a-push.phh
b/web/Obj/sac-a-push.phh
index
bc0ea87
..
4a325da
100644
(file)
--- a/
web/Obj/sac-a-push.phh
+++ b/
web/Obj/sac-a-push.phh
@@
-404,10
+404,18
@@
class Sac_a_push {
if (isset($this->s2u[intval($sock)])) {
$user = $this->s2u[intval($sock)];
$response = $user->rd_cache_get();
if (isset($this->s2u[intval($sock)])) {
$user = $this->s2u[intval($sock)];
$response = $user->rd_cache_get();
+ if (($this->curtime - $user->lacc) <= (EXPIRE_TIME_RD / 2)) {
+ $user->ping_req = FALSE;
+ }
if ($response == "") {
$content = "";
$user->stream_main($content, $get, $post, $cookie);
if ($response == "") {
$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
+ && (($this->curtime - $user->lacc) > (EXPIRE_TIME_RD / 2))) {
+ $content = $user->stream_ping();
+ $user->ping_req = TRUE;
+ }
if ($content == "" && $user->rd_kalive_is_expired($this->curtime)) {
$content = $user->stream_keepalive();
}
if ($content == "" && $user->rd_kalive_is_expired($this->curtime)) {
$content = $user->stream_keepalive();
}
diff --git
a/web/Obj/user.phh
b/web/Obj/user.phh
index
e94b4aa
..
b13f56e
100644
(file)
--- a/
web/Obj/user.phh
+++ b/
web/Obj/user.phh
@@
-941,6
+941,15
@@
push(null);
// -->
</script>", $this->rd_scristp++));
// -->
</script>", $this->rd_scristp++));
+}
+
+function stream_ping()
+{
+ return (sprintf("<script id='hs%d' type='text/javascript'><!--
+push(\"act_ping();\");
+// -->
+</script>", $this->rd_scristp++));
+
}
static function base_get()
}
static function base_get()
diff --git
a/web/briskin5/index_wr.php
b/web/briskin5/index_wr.php
index
d865972
..
fbc37c5
100644
(file)
--- a/
web/briskin5/index_wr.php
+++ b/
web/briskin5/index_wr.php
@@
-42,6
+42,7
@@
function bin5_index_wr_main(&$bri, $remote_addr, $get, $post, $cookie)
{
GLOBAL $G_base, $G_dbasetype;
{
GLOBAL $G_base, $G_dbasetype;
+ $curtime = time();
if ($bri == NULL) {
return FALSE;
}
if ($bri == NULL) {
return FALSE;
}
@@
-73,7
+74,10
@@
function bin5_index_wr_main(&$bri, $remote_addr, $get, $post, $cookie)
log_wr('POSTSPLIT: '.$argz[0].' user->stat: ['.$user->stat.']');
log_wr($user->step, 'bin::index_wr.php: after get_user()');
log_wr('POSTSPLIT: '.$argz[0].' user->stat: ['.$user->stat.']');
log_wr($user->step, 'bin::index_wr.php: after get_user()');
- if (false && $argz[0] == 'shutdown') {
+ if ($argz[0] == 'ping') {
+ $user->lacc = $curtime;
+ }
+ else if (false && $argz[0] == 'shutdown') {
log_auth($user_cur->sess, "Shutdown session. delegate to room gc the autologout");
log_rd2("bin5/index_wr.php: AUTO LOGOUT.");
log_auth($user_cur->sess, "Shutdown session. delegate to room gc the autologout");
log_rd2("bin5/index_wr.php: AUTO LOGOUT.");
@@
-481,7
+485,6
@@
function bin5_index_wr_main(&$bri, $remote_addr, $get, $post, $cookie)
$pt_cur = calculate_points(&$table);
$plist = "$table->table_token|$user->table_orig|$table->player_n";
$pt_cur = calculate_points(&$table);
$plist = "$table->table_token|$user->table_orig|$table->player_n";
- $curtime = time();
$ucodes = array();
for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
$user_cur = &$bri->user[$table->player[$i]];
$ucodes = array();
for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
$user_cur = &$bri->user[$table->player[$i]];
diff --git
a/web/commons.js
b/web/commons.js
index
94de832
..
f0ea078
100644
(file)
--- a/
web/commons.js
+++ b/
web/commons.js
@@
-329,6
+329,11
@@
function act_chatt(value)
}
/* Stat: ROOM */
}
/* Stat: ROOM */
+function act_ping()
+{
+ send_mesg("ping");
+}
+
function act_sitdown(table)
{
send_mesg("sitdown|"+table);
function act_sitdown(table)
{
send_mesg("sitdown|"+table);
diff --git
a/web/index_wr.php
b/web/index_wr.php
index
99213b7
..
6995a18
100644
(file)
--- a/
web/index_wr.php
+++ b/
web/index_wr.php
@@
-199,7
+199,10
@@
function index_wr_main(&$room, $remote_addr, $get, $post, $cookie)
log_wr($user->step, 'index_wr.php: after get_user()');
log_wr($user->step, 'index_wr.php: after get_user()');
- if ($argz[0] == 'shutdown') {
+ if ($argz[0] == 'ping') {
+ $user->lacc = $curtime;
+ }
+ else if ($argz[0] == 'shutdown') {
log_auth($user->sess, "Shutdown session.");
$user->reset();
log_auth($user->sess, "Shutdown session.");
$user->reset();