- if ($cur_step < $user->step) {
- do {
- if ($cur_step + COMM_N < $user->step) {
- if (($cur_stat != $user->stat)) {
- $to_stat = $user->stat;
- unlock_data($sem);
- ignore_user_abort(FALSE);
- return (page_sync($to_stat == "table" ? "table.php" : "index.php"));
- }
- log_rd2($sess, "lost history, refresh from scratch");
- $new_step = -1;
- break;
- }
- for ($i = $cur_step ; $i < $user->step ; $i++) {
- log_rd2($sess, "ADDED TO THE STREAM: ".$user->comm[$i % COMM_N]);
- $ret .= $user->comm[$i % COMM_N];
- }
- $new_stat = $user->stat;
- $new_subst = $user->subst;
- $new_step = $user->step;
- } while (0);
-
- if ($user->the_end == TRUE) {
- log_rd2($sess, "LOGOUT BYE BYE!!");
- log_auth($user->sess, "Explicit logout.");
- $tmp_sess = $user->sess;
- $user->sess = "";
- step_unproxy($tmp_sess);
-
- $user->name = "";
- $user->the_end = FALSE;
-
- if ($user->subst == 'sitdown')
- $bri->room_wakeup(&$user);
- else if ($user->subst == 'standup')
- $bri->room_outstandup(&$user);
- else
- log_rd2($sess, "LOGOUT FROM WHAT ???");
-
- save_data($bri);
- }
+ else {
+ // TODO: verify if we can use only $user struct
+ ignore_user_abort(TRUE);
+ $sem = Room::lock_data();
+ $S_load_stat['U_heavy']++;
+ if (($user = User::load_data($proxy_step['i'], $sess)) == FALSE) {
+ Room::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (unrecerror());
+ }
+
+ if ($cur_step < $user->step) {
+ do {
+ if ($cur_step + COMM_N < $user->step) {
+ if (($cur_stat != $user->stat)) {
+ $to_stat = $user->stat;
+ Room::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ log_load("RESYNC");
+ return (page_sync($user->sess, ($to_stat == "table" ? "briskin5/index.php" : "index.php"), $user->table, $user->table_token));
+ }
+ log_rd2("lost history, refresh from scratch");
+ $new_step = -1;
+ break;
+ }
+ for ($i = $cur_step ; $i < $user->step ; $i++) {
+ $ii = $i % COMM_N;
+ log_rd2("ADDED TO THE STREAM: ".$user->comm[$ii]);
+ $ret .= $user->comm[$ii];
+ }
+ $new_stat = $user->stat;
+ $new_subst = $user->subst;
+ $new_step = $user->step;
+ } while (0);
+
+ log_mop($user->step, 'index_rd.php: after ret set');
+
+ if ($user->the_end == TRUE) {
+ log_rd2("LOGOUT BYE BYE!!");
+ log_auth($user->sess, "Explicit logout.");
+
+ $S_load_stat['R_the_end']++;
+ if (($room = Room::load_data()) == FALSE) {
+ Room::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (unrecerror());
+ }
+
+ unset($user);
+ if (($user = $room->get_user($sess, $idx)) == FALSE) {
+ Room::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (unrecerror());
+ }
+ $user->reset();
+
+ if ($user->subst == 'sitdown') {
+ log_load("ROOM WAKEUP");
+ $room->room_wakeup($user);
+ }
+ else if ($user->subst == 'standup')
+ $room->room_outstandup($user);
+ else
+ log_rd2("LOGOUT FROM WHAT ???");
+
+ Room::save_data($room);
+ }
+ }
+
+ Room::unlock_data($sem);
+ ignore_user_abort(FALSE);