In the normal case - the same client reopening after having
given the connection up for lost - the message ends up on a
socket nobody reads any more, and does no harm. */
- $bye = $user->stream_bye('xstm.stop(); '
- .show_notify($mlang_brisk['sessmoved'][$G_lang], 0, "chiudi", 400, 120));
+ if ($user->rd_sess !== NULL && $user->rd_sess != $cookie['sess']) {
+ /* The old stream belonged to another session, which is
+ now orphaned: this is the "ghost swap" of add_user(),
+ that is a new access with the same name from another
+ browser. There it can be sent back to the login, where
+ ghost_sess explains that the session was assigned to
+ another browser, and since its old session is no longer
+ valid it does not come back in. */
+ $bye = $user->stream_bye(sprintf('xstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("%sindex.php");',
+ User::base_get()));
+ }
+ else {
+ /* Same session, two windows: it cannot be sent to the
+ login, because the session cookie is shared between the
+ tabs of the same browser and it would come straight back
+ in, taking the stream again, from the top. It is stopped
+ and told why. */
+ $bye = $user->stream_bye('xstm.stop(); '
+ .show_notify($mlang_brisk['sessmoved'][$G_lang], 0, "chiudi", 400, 120));
+ }
if ($bye != "") {
@fwrite($prev, $bye, mb_strlen($bye, "ASCII"));
}
public $pend_async; // number of async check that must be returned
public $rd_socket; // socket handle of push stream
+ public $rd_sess; // sessione con cui il flusso corrente e' stato aperto:
+ // it tells apart the one displaced by another window on
+ // the SAME session (which cannot go back to the login, the
+ // cookie is shared and it would come back in) from the one
+ // displaced by a new access with a different session
+ // (which must go back to the login, and finds the
+ // explanation there)
public $rd_endtime; // end time for push stream
public $rd_stat; // actual status of push stream
public $rd_subst; // actual substatus of push stream
$thiz->comm = array();
$thiz->rd_socket = NULL;
+ $thiz->rd_sess = NULL;
$thiz->rd_endtime = -1;
$thiz->rd_stat = -1;
$thiz->rd_subst = "";
}
}
$this->rd_socket = $sock;
+ /* the session the stream was opened with is recorded: when it gets
+ replaced, comparing it with the one of the newcomer tells whether it is
+ the same window-session or a different access */
+ $this->rd_sess = ($sock == NULL ? NULL : $this->sess);
}
function rd_kalive_get()
/* as in the room: the stream being replaced is told what
happened to it, otherwise it reopens and displaces the
new one in turn, forever. */
- $bye = $user->stream_bye('xstm.stop(); '
- .show_notify($mlang_brisk['sessmoved'][$G_lang], 0, "chiudi", 400, 120));
+ if ($user->rd_sess !== NULL && $user->rd_sess != $cookie['sess']) {
+ /* as in the room: different session, the old one is
+ orphaned and finds the explanation at the login */
+ $bye = $user->stream_bye(sprintf('xstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("%sindex.php");',
+ Bin5_user::base_get()));
+ }
+ else {
+ $bye = $user->stream_bye('xstm.stop(); '
+ .show_notify($mlang_brisk['sessmoved'][$G_lang], 0, "chiudi", 400, 120));
+ }
if ($bye != "") {
@fwrite($prev, $bye, mb_strlen($bye, "ASCII"));
}