示例#1
0
 public function onStart()
 {
     swoole_set_process_name("ansen: master process");
     //master进程名称
     $port = ZConfig::getField('socket', 'port');
     Debug::debug("server master start port[{$port}] pid[" . posix_getpid() . "]version " . SWOOLE_VERSION . "... \n");
     $timerConfigs = ZConfig::getField('socket', 'times');
     $params = func_get_args();
     //        var_dump($timerConfigs);
     if (!empty($timerConfigs)) {
         foreach ($timerConfigs as $time) {
             \swoole_server_addtimer($params[0], $time);
         }
     }
     //game start
     common\connection::setServer($params[0]);
     common\game::setRuncount();
     $count = common\game::getRuncount();
     Debug::log("begin game round[{$count}]\n");
     //when server restart
     $nowTime = time();
     $nextRunTime = common\game::getNextRunTime();
     if ($nowTime >= $nextRunTime) {
         $newNextRunTime = $nowTime + ZConfig::getField('init', 'firstRunTime');
         //set new next round
         common\game::setNextRunTime($newNextRunTime);
     }
     //:~end
 }