From d841ff52fc567de174bad9323d6bce06825f3762 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Fri, 4 Jan 2013 10:07:05 +0100 Subject: [PATCH] fix hard cabled stream_fini response when some error occurs --- TODO.txt | 4 +++- web/Obj/brisk.phh | 5 ++++- web/Obj/transports.phh | 10 ++++++++++ web/Obj/user.phh | 6 +++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/TODO.txt b/TODO.txt index b25fc15..40ebb1e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -4,11 +4,12 @@ MAJOR | -------+ - BUG: some connection to the named socket fails - - Page still opened after the server restart + - Not simultaneous more then one stream MINOR | -------+ WIP - try to be more antivirus-friendly + - multiple rows between games - packetize and automatize php-ancillary and apache module - into the room local step remains -1 - DISABLED_TO_FIX: DNS access (perform blocking dns requests, must be fixed) @@ -16,6 +17,7 @@ DONE | ------+ + DONE - Page still opened after the server restart DONE - log_legal address fix DONE - manage too fast reload in xynt-streaming DONE - add xhr as transport layer and manage different streams better diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 6249c43..f8c9225 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -2188,8 +2188,11 @@ class Room do { if (!isset($cookie['sess']) || (($user = $this->get_user($cookie['sess'], $idx)) == FALSE)) { - $content = User::stream_fini($s_a_p->rndstr, TRUE); + if (($transp = gpcs_var('transp', $get, $post, $cookie)) === FALSE) + $transp = "iframe"; + $content = User::stream_fini($transp, $s_a_p->rndstr, TRUE); + $s_a_p->pgflush_try_add($enc, $new_socket, 20, $header_out, $content); return TRUE; diff --git a/web/Obj/transports.phh b/web/Obj/transports.phh index e0b11ee..2d9714e 100644 --- a/web/Obj/transports.phh +++ b/web/Obj/transports.phh @@ -90,6 +90,7 @@ class Transport_xhr { static function fini($init_string, $base, $blockerr) { + return (sprintf('@BEGIN@ %s window.onbeforeunload = null; window.onunload = null; document.location.assign("%sindex.php"); @END@', ($blockerr ? 'xstm.stop(); ' : ''), $base)); return (""); } @@ -187,5 +188,14 @@ class Transport { return new Transport_iframe(); } } + static function gettype($transp) + { + if ($transp == 'xhr' || $transp == 'htmlfile') { + return "Transport_".$transp; + } + else { + return 'Transport_iframe'; + } + } } ?> \ No newline at end of file diff --git a/web/Obj/user.phh b/web/Obj/user.phh index b6efbcd..d5e82ee 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -651,13 +651,13 @@ class User { return ($ret); } // function maincheck (... - public static function stream_fini($init_string, $is_unrecoverable) + public static function stream_fini($transp, $init_string, $is_unrecoverable) { printf("xXx user::stream_fini\n"); // FIXME: dynamic "Transport_" type - $tans_class = "Transport_iframe"; - $body = $tans_class::fini($init_string, self::base_get(), static::blocking_error($is_unrecoverable)); + $trans_class = Transport::gettype($transp); + $body = $trans_class::fini($init_string, self::base_get(), static::blocking_error($is_unrecoverable)); // ELSE IF XHR THEN: // return (static::blocking_error($is_unrecoverable)); -- 2.17.1