X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Findex_rd.php;h=38a660edd753763c34b78f1b32d538eb3d99bdfc;hb=e58ff1b750cdb0e73657cea7bfeed86df22b4d3c;hp=f1af84dec71c81cb0abeb36fd6811e7513f8052c;hpb=bb4bd80920fcff2ce4fe07aef2faaa3f739b9d58;p=brisk.git diff --git a/web/index_rd.php b/web/index_rd.php index f1af84d..38a660e 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -21,7 +21,7 @@ * */ -require_once("brisk.phh"); +require_once("Obj/brisk.phh"); log_load($sess, "LOAD: index_rd.php ".$QUERY_STRING); @@ -50,12 +50,12 @@ function unrecerror() return (sprintf('the_end=true; window.onunload = null; document.location.assign("index.php");')); } -function page_sync($page) +function page_sync($sess, $page) { GLOBAL $is_page_streaming; $is_page_streaming = TRUE; - // log_rd2("PAGE_SYNC"); + log_rd2($sess, "PAGE_SYNC"); return (sprintf('the_end=true; window.onunload = null; document.location.assign("%s");', $page)); } @@ -67,30 +67,32 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su GLOBAL $is_page_streaming, $first_loop; $ret = FALSE; - $bri = FALSE; + $room = FALSE; - log_rd2($sess, "M"); + // log_rd2($sess, "M"); /* Sync check (read only without modifications */ ignore_user_abort(TRUE); - if (($sem = lock_data()) != FALSE) { + if (($sem = Room::lock_data()) != FALSE) { // Aggiorna l'expire time lato server if ($first_loop == TRUE) { - log_rd2($sess, "F"); - $bri = &load_data(); - if (($user = &$bri->get_user($sess, $idx)) == FALSE) { - unlock_data($sem); + log_only($sess, "F"); + $room = &Room::load_data(); + if (($user = &$room->get_user($sess, $idx)) == FALSE) { + Room::unlock_data($sem); ignore_user_abort(FALSE); return (unrecerror()); } log_auth($sess, "update lacc"); $user->lacc = time(); - $bri->garbage_manager(FALSE); + $room->garbage_manager(FALSE); - save_data($bri); + Room::save_data($room); $first_loop = FALSE; } - unlock_data($sem); + + log_only($sess, "U"); + Room::unlock_data($sem); ignore_user_abort(FALSE); } else { @@ -101,15 +103,37 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su // log_rd2($sess, "Postget".$proxy_step."zizi"); if ($cur_step == $proxy_step) { - log_rd2($sess, "P"); - return; + log_only2($sess, "P"); + return (FALSE); + } + else { + log_only2($sess, "R"); } } + else { + log_only2($sess, "R"); + } - if ($bri == FALSE) - $bri = &load_data(); - - if (($user = &$bri->get_user($sess, $idx)) == FALSE) { + if ($room == FALSE) { + do { + ignore_user_abort(TRUE); + if (($sem = Room::lock_data()) == FALSE) + break; + + log_only($sess, "P"); + if (($room = &Room::load_data()) == FALSE) + break; + } while (0); + + if ($sem != FALSE) + Room::unlock_data($sem); + + ignore_user_abort(FALSE); + if ($room == FALSE) + return (FALSE); + } + + if (($user = &$room->get_user($sess, $idx)) == FALSE) { return (unrecerror()); } @@ -122,10 +146,10 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su if ($cur_step == -1) { // FUNZIONE from_scratch DA QUI ignore_user_abort(TRUE); - $sem = lock_data(); - $bri = &load_data(); - if (($user = &$bri->get_user($sess, $idx)) == FALSE) { - unlock_data($sem); + $sem = Room::lock_data(); + $room = &Room::load_data(); + if (($user = &$room->get_user($sess, $idx)) == FALSE) { + Room::unlock_data($sem); ignore_user_abort(FALSE); return (unrecerror()); } @@ -139,23 +163,28 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su $user->trans_step = -1; - save_data($bri); - unlock_data($sem); + Room::save_data($room); + Room::unlock_data($sem); ignore_user_abort(FALSE); } else { log_rd2($sess, "TRANS NON ATTIVATO"); - unlock_data($sem); + Room::unlock_data($sem); ignore_user_abort(FALSE); } } if ($cur_step == -1) { - log_rd2($sess, "PRE-NEWSTAT."); + log_rd2($sess, "PRE-NEWSTAT: ".$user->stat); if ($user->stat == 'room') { log_rd($sess, "roomma"); - $ret .= show_room(&$bri, &$user); + $ret .= show_room(&$room, &$user); + + /* NOTE the sets went common */ + $new_stat = $user->stat; + $new_subst = $user->subst; + $new_step = $user->step; } /*************** * * @@ -163,22 +192,31 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su * * ***************/ else if ($user->stat == 'table') { - $ret = show_table(&$bri,&$user,$user->step,FALSE,FALSE); + /* FIXME we need to decide what do in this case + + if ($user->subst != "shutdowned" && $user->subst != "shutdowner") + $ret = show_table(&$room,&$user,$user->step,FALSE,FALSE); log_rd2($sess, "SENDED TO THE STREAM: ".$ret); + + + $new_stat = $user->stat; + $new_subst = $user->subst; + $new_step = $user->step; + */ + log_rd2($sess, "ALL COMMENTED: ".$ret); + + } log_rd2($sess, "NEWSTAT: ".$user->stat); - $new_stat = $user->stat; - $new_subst = $user->subst; - $new_step = $user->step; } else { ignore_user_abort(TRUE); - $sem = lock_data(); - $bri = &load_data(); - if (($user = &$bri->get_user($sess, $idx)) == FALSE) { - unlock_data($sem); + $sem = Room::lock_data(); + $room = &Room::load_data(); + if (($user = &$room->get_user($sess, $idx)) == FALSE) { + Room::unlock_data($sem); ignore_user_abort(FALSE); return (unrecerror()); } @@ -187,9 +225,10 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su if ($cur_step + COMM_N < $user->step) { if (($cur_stat != $user->stat)) { $to_stat = $user->stat; - unlock_data($sem); + Room::unlock_data($sem); ignore_user_abort(FALSE); - return (page_sync($to_stat == "table" ? "table.php" : "index.php")); + log_load($user->sess, "RESYNC"); + return (page_sync($user->sess, $to_stat == "table" ? "table.php" : "index.php")); } log_rd2($sess, "lost history, refresh from scratch"); $new_step = -1; @@ -214,18 +253,20 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su $user->name = ""; $user->the_end = FALSE; - if ($user->subst == 'sitdown') - $bri->room_wakeup(&$user); + if ($user->subst == 'sitdown') { + log_load($user->sess, "ROOM WAKEUP"); + $room->room_wakeup(&$user); + } else if ($user->subst == 'standup') - $bri->room_outstandup(&$user); + $room->room_outstandup(&$user); else log_rd2($sess, "LOGOUT FROM WHAT ???"); - save_data($bri); + Room::save_data($room); } } - unlock_data($sem); + Room::unlock_data($sem); ignore_user_abort(FALSE); } @@ -245,7 +286,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su */ $is_page_streaming = ((stristr($HTTP_USER_AGENT, "linux") && - stristr($HTTP_USER_AGENT, "firefox")) ? FALSE : TRUE); + (stristr($HTTP_USER_AGENT, "firefox") || stristr($HTTP_USER_AGENT, "iceweasel"))) ? FALSE : TRUE); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -279,8 +320,8 @@ for ($i = 0 ; time() < $endtime ; $i++) { $old_subst = $subst; $old_step = $step; // log_rd($sess, "POST MAIN ".$step);; - usleep(200000); - if (($i % 10) == 0) { + usleep(400000); + if (($i % 5) == 0) { // log_rd2($sess, "TIME: ".time()); echo '_'; flush();