public static function sleepAndTrigger() { # Trigger self::trigger(); # Sleep $elapsed = microtime(true) - self::$LAST_TIME; $elapsed *= 1000000; if ($elapsed < self::$MICROS) { usleep(self::$MICROS - $elapsed); } self::$LAST_TIME = microtime(true); }
public function onInitTimers() { Dog_Timer::addTimer(array($this, 'pullTimer'), null, 10.0); }
<?php $lang = array('en' => array('help' => 'Usage: %CMD%. Restart all timers.', 'ok' => 'Timers have been successfully flushed. %BOT% is sleeping for %d milliseconds each loop.')); $millis = Dog_Init::getSleepMillis(); Dog_Timer::flush(); Dog_Timer::init(Dog_Init::getSleepMillis()); Dog_Init::initTimers(); Dog::rply('ok', array($millis));
if (0 >= ($seconds = GWF_TimeConvert::humanToSeconds($seconds))) { return $plug->rply('err_seconds'); } if (GWF_Time::ONE_DAY * 8 < $seconds) { return $plug->rply('err_too_long'); } // Try to parse back duration from parsed seconds if (false === ($delay = GWF_TimeConvert::humanDurationISO(Dog::getLangISO(), $seconds))) { return $plug->rply('err_seconds'); } $user = Dog::getUser(); if (!isset($DOG_PLUG_ALERT_TIMERS[$user->getID()])) { $DOG_PLUG_ALERT_TIMERS[$user->getID()] = 0; } if ($DOG_PLUG_ALERT_TIMERS[$user->getID()] >= 3) { return $plug->rply('err_too_much'); } if (!function_exists('dog_plugin_alert_func4')) { function dog_plugin_alert_func4(array $args) { global $DOG_PLUG_ALERT_TIMERS; $scope = $args[0]; $scope instanceof Dog_Scope; Dog::setScope($scope); Dog::reply($args[1]); $DOG_PLUG_ALERT_TIMERS[$scope->getUser()->getID()]--; } } Dog_Timer::addTimer('dog_plugin_alert_func4', array(Dog::getScope(), $plug->argvMsgFrom(1)), $seconds, false); $DOG_PLUG_ALERT_TIMERS[$user->getID()]++; $plug->rply('msg_remember', array($delay));
public static function shadowTimer() { # 1 second over in the Shadowlamb world. self::$sr_timestamp = GWF_Counter::getAndCount('SR4_TIME', self::SECONDS_PER_TICK); # Execute Web Commands // self::shadowTimerWebcommands(); if (defined('SL4_REALS')) { self::shadowTimerRealNPCs(); } # All parties: $partyids = array_keys(self::$parties); shuffle($partyids); # Shuffle which party goes first to have evenly distributed winners in race conditions. foreach ($partyids as $id) { # still there? if (isset(self::$parties[$id])) { if (self::$parties[$id]->getTimestamp() < time() - self::KICK_IDLE_TIMEOUT) { self::removeParty(self::$parties[$id]); } else { self::$parties[$id] instanceof SR_Party; self::$parties[$id]->timer(self::$sr_timestamp); } } } # Next tick in one second pls. Dog_Timer::addTimer(array(__CLASS__, 'shadowTimer'), NULL, self::TICKLEN, false); }
public function onInitTimers() { Dog_Timer::addTimer(array($this, 'randomQuote'), NULL, 60); }
public function onInitTimers() { Dog_Timer::addTimer(array($this, 'onTimer'), NULL, 60); }
public static function initTimerTrig($entry, $fullpath, $data) { list($server, $repeat, $seconds) = $data; Dog_Timer::addTimer($fullpath, $server, $seconds, $repeat); }
private function ai_idle($delay = 15) { Dog_Timer::addTimer(array($this, 'on_idled'), array(), $delay); }
public static function mainloop() { Dog_Log::debug('Dog::mainloop() - start'); while (!Dog_Launcher::shouldRestart()) { foreach (self::$SERVERS as $server) { $server instanceof Dog_Server; if ($server->isActive()) { self::processServer($server); } } Dog_Timer::sleepAndTrigger(); self::$WORKER->executeCallbacks(); } Dog_Launcher::cleanup(); Dog_Log::debug('Dog::mainloop() - exited'); }
public function onInitTimers() { Dog_Timer::addTimer(array($this, 'claim'), null, 120); }