Example #1
0
 function ret($msg = NULL)
 {
     always_pre(get_defined_vars());
     if (empty($msg)) {
         $msg = debug_backtrace();
     }
     $ret['log'] = $this->log;
     $ret['msg'] = $msg;
     always_pre($ret);
     exit;
 }
 function poll()
 {
     always_pre(get_defined_vars());
     $this->args = $this->sanitize_input();
     // always_pre(json_encode($args));
     extract($this->args);
     if (empty($id) || empty($last_updated) || empty($player_id)) {
         throw new Exception('Required arg missing from id|last_update|player_id');
     }
     $this->register_game_activity($id, $player_id);
     //Max execution time: 25s
     while (time() - $this->start_time < 25) {
         $update = $this->check_state_changes($id, $last_updated);
         if (!is_null($update)) {
             $this->ret($update);
         }
         $this->log[microtime()] = 'continuing';
         usleep(100000);
         continue;
     }
     $this->ret('timeout');
 }