ping_req attribute added to User class
[brisk.git] / web / Obj / user.phh
index 96706b8..a59cc44 100644 (file)
@@ -119,6 +119,8 @@ class User {
   var $subst;      // substatus for each status   
   var $step;       // step of the current status
   var $trans_step; // step to enable transition between pages (disable == -1)
+  var $cl_step;    // current step returned by client
+  var $ping_req;   // ping is already requested ?
 
   var $rd_socket;  // socket handle of push stream
   var $rd_endtime; // end time for push stream
@@ -129,6 +131,7 @@ class User {
   var $rd_scristp; // current script step (for each session) 
   var $rd_kalive;  // if no message are sent after RD_KEEPALIVE_TOUT secs we send a keepalive from server
   var $rd_cache;   // place where store failed fwrite data
+  var $rd_toflush; // bool to inform about unfflushed socket
   var $rd_zls;     // zlibstream object handle if compressed stream, else FALSE
   var $rd_transp;  // class that define stream encapsulation type (iframe, xhr, ...)
   var $rd_is_chunked; // is the transport chunked or not ?
@@ -179,6 +182,8 @@ class User {
     $thiz->subst      = $subst;
     $thiz->step       = 1;
     $thiz->trans_step = -1;
+    $thiz->cl_step    = -1;
+    $thiz->ping_req   = FALSE;
     $thiz->comm       = array();
 
     $thiz->rd_socket  = NULL;
@@ -190,9 +195,11 @@ class User {
     $thiz->rd_scristp = -1;
     $thiz->rd_kalive  = -1;
     $thiz->rd_cache   = "";
+    $thiz->td_toflush = FALSE;
     $thiz->rd_zls     = FALSE;
     $thiz->rd_transp  = NULL;
     $thiz->rd_is_chunked = FALSE;
+    $thiz->ping_req   = FALSE;
 
     $thiz->asta_card  = -2;
     $thiz->asta_pnt   = -1;
@@ -231,6 +238,8 @@ class User {
     $this->subst      = $from->subst;
     $this->step       = $from->step;
     $this->trans_step = $from->trans_step;
+    $this->cl_step    = $from->cl_step;
+    $this->ping_req   = $from->ping_req;
     $this->comm       = array();
 
     $i_start = (1 > ($from->step - COMM_N) ? 1 : ($from->step - COMM_N)); 
@@ -294,6 +303,8 @@ class User {
     $thiz->subst      = $from->subst;
     $thiz->step       = $from->step;
     $thiz->trans_step = $from->trans_step;
+    $thiz->cl_step    = $from->cl_step;
+    $thiz->ping_req   = $from->ping_req;
     $thiz->comm       = array();
 
     /*
@@ -339,6 +350,18 @@ class User {
       return (($this->flags & USER_FLAG_AUTH) && ($this->flags & USER_FLAG_TY_CERT));
   }
 
+  function is_empty()
+  {
+      return ($this->sess == "");
+  }
+
+  function is_active()
+  {
+      if ($this->sess != "" && !$this->the_end) // OK: is_active()
+          return TRUE;
+      return FALSE;
+  }
+
   function flags_set($flags, $mask)
   {
       $flags_old = $this->flags & (~$mask);
@@ -378,7 +401,7 @@ class User {
       $this->rd_endtime = $curtime + RD_ENDTIME_DELTA;
       $this->rd_stat    = $stat;
       $this->rd_subst   = $subst;
-      $this->rd_step    = $step;
+      $this->rd_step    = $step; // TRACKED
       $this->rd_from    = $from;
       $this->rd_scristp = 0;
       $this->rd_kalive  = $curtime + RD_KEEPALIVE_TOUT;
@@ -611,9 +634,9 @@ class User {
 
       log_rd("maincheck begin");
       
-      $ret = FALSE;
+      $ret = "";
       $curtime = time();
-      
+
       /* Nothing changed, return. */
       if ($this->rd_step == $this->step)
           return (FALSE);
@@ -621,19 +644,13 @@ class User {
       log_rd2("do other cur_stat[".$this->rd_stat."] user->stat[".$this->stat."] cur_step[".$this->rd_step."] user_step[".$this->step."]");
       
       if ($this->rd_step == -1) {
-          /*
-           *  if $this->rd_step == -1 load the current state from the main struct
-           */
-          
+          /*  if $this->rd_step == -1 load the current state from the main struct  */
           $S_load_stat['wR_minusone']++;
-          
-          // if ($this->the_end == TRUE) {
-          // log_rd2("main_check: the end".var_export(debug_backtrace()));
-          // }
-          
+
           if ($this->trans_step != -1) {
               log_rd2("TRANS USATO ".$this->trans_step);
-              $this->rd_step = $this->trans_step;
+              $this->rd_step = $this->step = $this->trans_step; // TRACKED
+              $ret .= $this->room->show_room($this->step, $this);
               $this->trans_step = -1;
           }
           else {
@@ -648,7 +665,6 @@ class User {
           
           if ($this->stat == 'room') {
               log_rd("roomma ".$this->step);
-              $curtime = time();
               if ($this->rec !== FALSE) {
                   $doc_filepath = $G_base.$G_doc_path.sprintf($G_tos_fname, $G_tos_vers, $G_lang);
                   $doc_filename = basename($doc_filepath);
@@ -696,7 +712,7 @@ class User {
               /* NOTE the sets went common */
               $this->rd_stat =  $this->stat;
               $this->rd_subst = $this->subst;
-              $this->rd_step =  $this->step;
+              $this->rd_step =  $this->step; // TRACKED
           }
           /***************
            *             *
@@ -740,32 +756,18 @@ class User {
                   }
                   $this->rd_stat =  $this->stat;
                   $this->rd_subst = $this->subst;
-                  $this->rd_step =  $this->step;
+                  $this->rd_step = $this->step;
               } while (0);
               
               log_rd2($this->step, 'index_rd.php: after ret set');
-              
-              if ($this->the_end == TRUE) {
-                  log_rd2("LOGOUT BYE BYE!!");
-                  log_auth($this->sess, "Explicit logout.");
-                  
-                  if ($this->the_end == TRUE) {
-                      $this->reset();
-                      
-                      if ($this->subst == 'sitdown') {
-                          log_load("ROOM WAKEUP");
-                          $this->room->room_wakeup($this);
-                      }
-                      else if ($this->subst == 'standup')
-                          $this->room->room_outstandup($this);
-                      else
-                          log_rd2("LOGOUT FROM WHAT ???");
-                      
-                  } /* if ($this->the_end == TRUE) { ... */
-              } /* if ($this->the_end == TRUE) { ... */
+
+              // if ($this->the_end == TRUE) { management is moved
+              // in the spush scope
           } /* if ($this->rd_step < $this->step) { */
       }  /* else of if ($this->rd_step == -1) { */
-      
+
+      if ($ret == "")
+          $ret = FALSE;
     
       return ($ret);
   }  //   function maincheck(...