force uncompress when websocket streaming and updated version
[brisk.git] / web / Obj / brisk.phh
index b480917..090aa8d 100644 (file)
@@ -141,12 +141,12 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi',
 $G_lng = langtolng($G_lang);
 
 $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "4.7.3";
+$G_brisk_version = "4.9.1";
 
 /* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: prova il nuovo azioni->preferenze.',
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: aggiunto WebSocket come sistema preferenziale di comunicazione e corretti un paio di bug.',
                                        'Se vuoi iscriverti alla <a target="_blank" href="mailto:ml-briscola+subscribe@milug.org">Mailing List</a>, cliccala!' ),
-                       'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: server-side infrastructure to manage user preferences added and S customization added.',
+                       'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: added WebSocket as preferential communication system and fixed a couple of bugs.',
                                        'If you want to subscribe our <a target="_blank" href="ml-briscola+subscribe@milug.org">Mailing List</a>, click it!' ) );
 
 $G_room_help = array( 'it' => '
@@ -1292,54 +1292,53 @@ class Room
 
   function room_sitdown($user, $table_idx)
   {
-    log_main("room_sitdown ".($user == FALSE ? "USER: FALSE" : "USER: ".$user->name));
-
-    $train_app = "";
-
-    if ($table_idx > -1 && $table_idx < TABLES_N) { 
-      $table = $this->table[$table_idx];
-
-      // wagon shutdown 
-      if ($table->wag_own != -1 && $table->player_n == PLAYERS_N) {        
-        for ($i = 0 ; $i < TABLES_N ; $i++) {
-            if ($table->wag_own == $table->player[$i]) {
-                $train_app = sprintf("tra.rem(%d); ", $table_idx); 
-                $table->wag_reset(time());
-                break;
-            }
-       }
-      }
-    }
-
-    for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
-      $ret = "";
-      $user_cur = $this->user[$i];
-      if ($user_cur->sess == '' || $user_cur->stat != 'room')
-      continue;
+      log_main("room_sitdown ".($user == FALSE ? "USER: FALSE" : "USER: ".$user->name));
       
-      $ret = "gst.st = ".($user_cur->step+1)."; ".$train_app;
-      if ($table_idx > -1)
-      $ret .= $this->table_content($user_cur, $table_idx);
-      $ret .= $this->standup_content($user_cur);
+      $train_app = "";
       
-      if ($user->idx_get() == $i) {
-       $ret .=  'subst = "sitdown"; tra.hide(); ';
-       // clean the action buttons in other tables
-       for ($e = 0 ; $e < TABLES_N ; $e++) {
-         // $ret .= table_act_content(FALSE, 0, $e, $user_cur->table, FALSE);
-          $ret .= $this->table[$e]->act_content($user_cur);
-       }
+      if ($table_idx > -1 && $table_idx < TABLES_N) { 
+          $table = $this->table[$table_idx];
+          
+          // wagon shutdown 
+          if ($table->wag_own != -1 && $table->player_n == PLAYERS_N) {        
+              for ($i = 0 ; $i < TABLES_N ; $i++) {
+                  if ($table->wag_own == $table->player[$i]) {
+                      $train_app = sprintf("tra.rem(%d); ", $table_idx); 
+                      $table->wag_reset(time());
+                      break;
+                  }
+              }
+          }
       }
-      else if ($table_idx > -1) {
-       if ($table->player_n == PLAYERS_N) {
-         // $ret .= table_act_content(($user_cur->subst == 'standup'), PLAYERS_N, $table_idx, $user_cur->table,
-          ///                      ($table->auth_only == FALSE ? TRUE : $user_cur->flags & USER_FLAG_AUTH));
-          $ret .= $table->act_content($user_cur);
-       }
+      
+      for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+          $ret = "";
+          $user_cur = $this->user[$i];
+          if ($user_cur->sess == '' || $user_cur->stat != 'room')
+              continue;
+          
+          $ret = "gst.st = ".($user_cur->step+1)."; ".$train_app;
+          if ($table_idx > -1)
+              $ret .= $this->table_content($user_cur, $table_idx);
+          $ret .= $this->standup_content($user_cur);
+          
+          if ($user->idx_get() == $i) {
+              $ret .=  'subst = "sitdown"; tra.hide(); ';
+              // clean the action buttons in other tables
+              for ($e = 0 ; $e < TABLES_N ; $e++) {
+                  $ret .= $this->table[$e]->act_content($user_cur);
+              }
+          }
+          else if ($table_idx > -1) {
+              if ($table->player_n == PLAYERS_N) {
+                  // $ret .= table_act_content(($user_cur->subst == 'standup'), PLAYERS_N, $table_idx, $user_cur->table,
+                  ///                      ($table->auth_only == FALSE ? TRUE : $user_cur->flags & USER_FLAG_AUTH));
+                  $ret .= $table->act_content($user_cur);
+              }
+          }
+          $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+          $user_cur->step_inc();
       }
-      $user_cur->comm[$user_cur->step % COMM_N] = $ret;
-      $user_cur->step_inc();
-    }
   }
 
   function chatt_send($user, $mesg)
@@ -2297,6 +2296,8 @@ class Room
 
   function request_mgr(&$s_a_p, $header, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie)
   {
+      GLOBAL $G_black_list;
+
       printf("NEW_SOCKET (root): %d PATH [%s]\n", intval($new_socket), $path);
 
       $enc = get_encoding($header);
@@ -2343,11 +2344,14 @@ class Room
 
           break;
       case "index_rd_ifra.php":
+          if (($transp  = gpcs_var('transp', $get, $post, $cookie)) === FALSE)
+              $transp = "iframe";
+          if ($transp == 'websocket')
+              $enc = 'plain';
+
           do {
               if (!isset($cookie['sess'])
                   || (($user = $this->get_user($cookie['sess'], $idx)) == FALSE)) {
-                  if (($transp  = gpcs_var('transp', $get, $post, $cookie)) === FALSE)
-                      $transp = "iframe";
                   
                   $content = User::stream_fini($transp, $s_a_p->rndstr, TRUE);
 
@@ -2365,9 +2369,8 @@ class Room
               }
 
               $content = "";
-              $user->stream_init($s_a_p->rndstr, $enc, $header_out, $content, $get, $post, $cookie);
-              
-              $response = headers_render($header_out, -1).chunked_content($user->rd_zls_get(), $content);
+              $user->stream_init($s_a_p->rndstr, $enc, $header, $header_out, $content, $get, $post, $cookie);
+              $response = headers_render($header_out, -1).$user->chunked_content($content);
               $response_l = mb_strlen($response, "ASCII");
               
               $wret = @fwrite($new_socket, $response, $response_l);