Example #1
0
 public function onTimer()
 {
     $params = func_get_args();
     //$serv = $paramet_s[0];
     $interval = $params[1];
     //ms
     switch ($interval) {
         case 1000:
             //rungame
             $count = common\game::getRuncount();
             Debug::log("check execute game round[{$count}]\n");
             $nextRunTime = common\game::getNextRunTime();
             if ($nextRunTime == time()) {
                 //get pre round data
                 common\game::run();
                 $count = common\game::getRuncount();
                 Debug::log("calculate round[{$count}] data to client over.\n");
                 common\game::setRuncount();
                 $count = common\game::getRuncount();
                 Debug::log("begin game round[{$count}]\n");
             }
             break;
         case 10000:
             $list = common\connection::online();
             $onlineUsers = count($list);
             Debug::debug("{$interval} ms online users[{$onlineUsers}].\n");
             print_r($list);
             break;
     }
 }