本文整理汇总了PHP中PHPDaemon\Core\Daemon::uncaughtExceptionHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::uncaughtExceptionHandler方法的具体用法?PHP Daemon::uncaughtExceptionHandler怎么用?PHP Daemon::uncaughtExceptionHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPDaemon\Core\Daemon
的用法示例。
在下文中一共展示了Daemon::uncaughtExceptionHandler方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: eventCall
/**
* Called when timer is triggered
* @return void
*/
public function eventCall()
{
try {
//Daemon::log('cb - '.Debug::zdump($this->cb));
call_user_func($this->cb, $this);
} catch (\Exception $e) {
Daemon::uncaughtExceptionHandler($e);
}
}
示例2: updateServer
public function updateServer($server)
{
if (!isset($server['address'])) {
return;
}
$server['address'] = trim($server['address']);
$app = $this;
if (isset($app->jobMap[$server['address']])) {
//\PHPDaemon\Daemon::log('already doing: '.$server['address']);
return;
}
$job = new \PHPDaemon\Core\ComplexJob(function ($job) use($app, $server) {
unset($app->jobMap[$server['address']]);
//\PHPDaemon\Daemon::log('Removed job for '.$server['address']. ' ('.sizeof($app->jobMap).')');
$set = $job->results['info'];
$set['address'] = $server['address'];
$set['players'] = $job->results['players'];
$set['latency'] = $job->results['latency'];
$set['atime'] = time();
if (0) {
\PHPDaemon\Core\Daemon::log('Updated server (' . round(memory_get_usage(true) / 1024 / 1024, 5) . '): ' . $server['address'] . ' latency = ' . round($set['latency'] * 1000, 2) . ' ==== ' . (isset($server['atime']) ? round($set['atime'] - $server['atime']) . ' secs. from last update.' : ' =---= ' . json_encode($server)));
}
try {
$app->servers->upsert(['_id' => $server['_id']], ['$set' => $set]);
} catch (\MongoException $e) {
\PHPDaemon\Core\Daemon::uncaughtExceptionHandler($e);
$app->servers->upsert(['_id' => $server['_id']], ['$set' => ['atime' => time()]]);
}
});
$app->jobMap[$server['address']] = $job;
//\PHPDaemon\Daemon::log('Added job for '.$server['address']);
$job('info', function ($jobname, $job) use($app, $server) {
$app->client->requestInfo($server['address'], function ($conn, $result) use($app, $server, $jobname, $job) {
$job('players', function ($jobname, $job) use($app, $server, $conn) {
$conn->requestPlayers(function ($conn, $result) use($app, $jobname, $job) {
$job->setResult($jobname, $result);
$conn->finish();
});
});
$job->setResult($jobname, $result);
});
});
$job('latency', function ($jobname, $job) use($app, $server) {
$app->client->ping($server['address'], function ($conn, $result) use($app, $jobname, $job) {
$job->setResult($jobname, $result);
$conn->finish();
});
});
$job();
}
示例3: onFrame
/**
* onFrame
* @param string $msg [@todo description]
* @param integer $type [@todo description]
* @return void
*/
public function onFrame($msg, $type)
{
$frames = json_decode($msg, true);
if (!is_array($frames)) {
return;
}
$this->route->onWakeup();
foreach ($frames as $frame) {
try {
$this->route->onFrame($frame, \PHPDaemon\Servers\WebSocket\Pool::STRING);
} catch (\Exception $e) {
Daemon::uncaughtExceptionHandler($e);
}
}
$this->route->onSleep();
}
示例4: onFrame
/**
* Called when new frame received.
* @param string $data Frame's data.
* @param string $type Frame's type ("STRING" OR "BINARY").
* @return boolean Success.
*/
public function onFrame($data, $type)
{
if (!isset($this->route)) {
return false;
}
try {
$this->route->onWakeup();
$this->route->onFrame($data, $type);
} catch (\Exception $e) {
Daemon::uncaughtExceptionHandler($e);
}
$this->route->onSleep();
return true;
}
示例5: onStateEv
/**
* Called when the connection state changed
* @param object $bev EventBufferEvent
* @param integer $events Events
* @return void
*/
public function onStateEv($bev, $events)
{
if ($events & \EventBufferEvent::CONNECTED) {
$this->onWriteEv($bev);
} elseif ($events & (\EventBufferEvent::ERROR | \EventBufferEvent::EOF | \EventBufferEvent::TIMEOUT)) {
try {
if ($this->finished) {
return;
}
if ($events & \EventBufferEvent::ERROR) {
$errno = \EventUtil::getLastSocketErrno();
if ($errno !== 0) {
$this->log('Socket error #' . $errno . ':' . \EventUtil::getLastSocketError());
}
if ($this->ssl && $this->bev) {
while ($err = $this->bev->sslError()) {
$this->log('EventBufferEvent SSL error: ' . $err);
}
}
}
$this->finished = true;
$this->onFinish();
$this->close();
} catch (\Exception $e) {
Daemon::uncaughtExceptionHandler($e);
}
}
}
示例6: finish
/**
* Finish the request
* @param integer Optional. Status. 0 - normal, -1 - abort, -2 - termination
* @param boolean Optional. Zombie. Default is false
* @return void
*/
public function finish($status = 0, $zombie = false)
{
if ($this->state === Generic::STATE_FINISHED) {
return;
}
if (!$zombie) {
$this->state = Generic::STATE_FINISHED;
}
if (!($r = $this->running)) {
$this->onWakeup();
}
while (($cb = array_shift($this->shutdownFuncs)) !== null) {
try {
$cb($this);
} catch (\Exception $e) {
Daemon::uncaughtExceptionHandler($e);
// @TODO: break?
}
}
if (!$r) {
$this->onSleep();
}
$this->event('finish');
$this->onFinish();
$this->cleanupEventHandlers();
if (Daemon::$compatMode) {
return;
}
++Daemon::$process->counterGC;
if (Daemon::$compatMode) {
return;
}
if (!Daemon::$obInStack) {
// preventing recursion
ob_flush();
}
if ($status !== -1) {
$appStatus = 0;
$this->postFinishHandler(function () use($appStatus, $status) {
$this->upstream->endRequest($this, $appStatus, $status);
$this->free();
});
} else {
$this->free();
}
}
示例7: onFailureEv
/**
* Called when the connection failed
* @param EventBufferEvent $bev
* @return void
*/
public function onFailureEv($bev = null)
{
try {
if (!$this->connected && !$this->failed) {
$this->failed = true;
$this->onFailure();
}
$this->connected = false;
} catch (\Exception $e) {
Daemon::uncaughtExceptionHandler($e);
}
}