本文整理汇总了PHP中Daemon类的典型用法代码示例。如果您正苦于以下问题:PHP Daemon类的具体用法?PHP Daemon怎么用?PHP Daemon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Daemon类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: onFileChanged
public function onFileChanged($path)
{
if (!Daemon::lintFile($path)) {
Daemon::log(__METHOD__ . ': Detected parse error in ' . $path);
return;
}
foreach ($this->files[$path] as $k => $subscriber) {
if (is_callable($subscriber) || is_array($subscriber)) {
call_user_func($subscriber, $path);
continue;
}
if (!isset(Daemon::$process->workers->threads[$subscriber])) {
unset($this->files[$path][$k]);
continue;
}
$worker = Daemon::$process->workers->threads[$subscriber];
if (Daemon::$config->autoreimport->value) {
if ($worker->connection) {
$worker->connection->sendPacket(array('op' => 'importFile', 'path' => $path));
}
} else {
$worker->signal(SIGUSR2);
}
}
}
开发者ID:J3FF3,项目名称:phpdaemon,代码行数:25,代码来源:FileWatcher.php
示例2: onReady
/**
* Called when the worker is ready to go
*
* @return void
*/
public function onReady()
{
// Adding listener
// ComplexJob - STATE_WAITING
$job = new ComplexJob(function ($job) {
// ComplexJob - STATE_DONE
/*array (
'bar' =>
array (
'job' => 'bar',
'success' => false,
'line' => 63,
),
'foo' =>
array (
'job' => 'foo',
'success' => true,
'line' => 84,
'arg' =>
array (
'param' => 'value',
),
),
'baz' =>
array (
'job' => 'baz',
'success' => false,
'line' => 94,
),
)*/
Daemon::log($job->results);
});
// Adding listener
// ComplexJob - STATE_WAITING
$job->addListener(function ($job) {
// ComplexJob - STATE_DONE
});
// Incapsulate some property in job
$job->appInstance = $this;
// Adding async job foo
$job('foo', $this->foo(array('param' => 'value')));
// Adding with 1 sec delay
Timer::add(function ($event) use($job) {
// Adding async job bar
$job('bar', function ($jobname, $job) {
Timer::add(function ($event) use($jobname, $job) {
// Job done
$job->setResult($jobname, array('job' => 'bar', 'success' => false, 'line' => __LINE__));
$event->finish();
}, 1000.0 * 50);
});
// Adding async job baz. Equal $job('baz', $job->appInstance->baz());
$job->addJob('baz', $job->appInstance->baz());
// Run jobs. All listeners will be called when the jobs done
// ComplexJob - STATE_RUNNING
$job();
$event->finish();
}, 1000000.0 * 1);
}
开发者ID:ruslanchek,项目名称:phpdaemon,代码行数:64,代码来源:ExampleComplexJob.php
示例3: stdin
public function stdin($buf)
{
// from mysqld to client.
if (Daemon::$settings['mod' . $this->appInstance->modname . 'protologging']) {
Daemon::log('MysqlProxy: Server --> Client: ' . Daemon::exportBytes($buf) . "\n\n");
}
$this->downstream->write($buf);
}
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:8,代码来源:MySQLProxy.php
示例4: init
public function init()
{
Daemon::$settings += array('mod' . $this->modname . 'listen' => 'tcp://0.0.0.0', 'mod' . $this->modname . 'listenport' => 23, 'mod' . $this->modname . 'enable' => 0);
if (Daemon::$settings['mod' . $this->modname . 'enable']) {
Daemon::log(__CLASS__ . ' up.');
$this->bindSockets(Daemon::$settings['mod' . $this->modname . 'listen'], Daemon::$settings['mod' . $this->modname . 'listenport']);
}
}
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:8,代码来源:TelnetHoneypot.php
示例5: init
public function init()
{
Daemon::$settings += array('mod' . $this->modname . 'listen' => 'tcp://0.0.0.0', 'mod' . $this->modname . 'listenport' => 1080, 'mod' . $this->modname . 'auth' => 0, 'mod' . $this->modname . 'username' => 'User', 'mod' . $this->modname . 'password' => 'Password', 'mod' . $this->modname . 'enable' => 0);
if (Daemon::$settings['mod' . $this->modname . 'enable']) {
Daemon::log(__CLASS__ . ' up.');
$this->bindSockets(Daemon::$settings['mod' . $this->modname . 'listen'], Daemon::$settings['mod' . $this->modname . 'listenport'], TRUE);
}
}
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:8,代码来源:SocksServer.php
示例6: stdin
/**
* Called when new data received
* @param string New data
* @return void
*/
public function stdin($buf)
{
Daemon::log(Debug::exportBytes($buf));
while ($c = array_pop($this->callbacks)) {
list($cb, $st) = $c;
$cb(microtime(true) - $st);
}
}
开发者ID:J3FF3,项目名称:phpdaemon,代码行数:13,代码来源:PingClient.php
示例7: getDaemonIds
public function getDaemonIds()
{
if (!$this->daemonIds) {
$cmd = Daemon::model()->getDbConnection()->createCommand('select `id` from `daemon`');
$this->daemonIds = $cmd->queryColumn();
}
return $this->daemonIds;
}
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:8,代码来源:McBridge.php
示例8: init
public function init()
{
Daemon::addDefaultSettings(array('mod' . $this->modname . 'listen' => 'tcp://0.0.0.0', 'mod' . $this->modname . 'listenport' => 8818, 'mod' . $this->modname . 'passphrase' => 'secret', 'mod' . $this->modname . 'enable' => 0));
if (Daemon::$settings['mod' . $this->modname . 'enable']) {
Daemon::log(__CLASS__ . ' up.');
$this->bindSockets(Daemon::$settings['mod' . $this->modname . 'listen'], Daemon::$settings['mod' . $this->modname . 'listenport']);
}
}
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:8,代码来源:DebugConsole.php
示例9: onFrame
/**
* Called when new frame received.
* @param string Frame's contents.
* @param integer Frame's type.
* @return void
*/
public function onFrame($data, $type)
{
if ($data === 'ping') {
$this->client->sendFrame('pong', WebSocketSERVER::STRING, function ($client) {
Daemon::log('ExampleWebSocket: \'pong\' received by client.');
});
}
}
开发者ID:J3FF3,项目名称:phpdaemon,代码行数:14,代码来源:ExampleWebSocket.php
示例10: init
public function init()
{
Daemon::addDefaultSettings(array('mod' . $this->modname . 'listen' => 'tcp://0.0.0.0', 'mod' . $this->modname . 'listenport' => 843, 'mod' . $this->modname . 'file' => Daemon::$dir . '/conf/crossdomain.xml', 'mod' . $this->modname . 'enable' => 0));
if (Daemon::$settings['mod' . $this->modname . 'enable']) {
Daemon::log(__CLASS__ . ' up.');
$this->bindSockets(Daemon::$settings['mod' . $this->modname . 'listen'], Daemon::$settings['mod' . $this->modname . 'listenport']);
$this->update();
}
}
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:9,代码来源:FlashPolicy.php
示例11: init
public static function init()
{
if (!(self::$supported = extension_loaded('eio'))) {
Daemon::log('FS: missing pecl-eio, Filesystem I/O performance compromised. Consider installing pecl-eio.');
return;
}
self::$fdCache = new CappedCacheStorageHits(self::$fdCacheSize);
eio_init();
}
开发者ID:ruslanchek,项目名称:phpdaemon,代码行数:9,代码来源:FS.php
示例12: addRoute
/**
* Adds a route if it doesn't exist already.
* @param string Route name.
* @param mixed Route's callback.
* @return boolean Success.
*/
public function addRoute($route, $cb)
{
if (isset($this->routes[$route])) {
Daemon::log(__METHOD__ . ' Route \'' . $route . '\' is already defined.');
return false;
}
$this->routes[$route] = $cb;
return true;
}
开发者ID:ruslanchek,项目名称:phpdaemon,代码行数:15,代码来源:WebSocketServer.php
示例13: onFrame
/**
* Called when new frame received.
* @param string Frame's contents.
* @param integer Frame's type.
* @return void
*/
public function onFrame($data, $type)
{
if ($data === 'ping') {
$this->client->sendFrame('pong', 'STRING', function ($client) {
// optional. called when the frame is transmitted to the client
Daemon::log('ExampleWebSocket: \'pong\' received by client.');
});
}
}
开发者ID:ruslanchek,项目名称:phpdaemon,代码行数:15,代码来源:ExampleWebSocket.php
示例14: proxy
/**
* Returns a proxy callback function with logging for debugging purposes
* @param callable $cb Callback
* @param mixed $name Data
* @return callable
*/
public static function proxy($cb, $name = null)
{
static $i = 0;
$n = ++$i;
Daemon::log('Debug::proxy #' . $n . ': SPAWNED (' . json_encode($name) . ')');
return function (...$args) use($cb, $name, $n) {
Daemon::log('Debug::proxy #' . $n . ': CALLED (' . json_encode($name) . ')');
$cb(...$args);
};
}
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:16,代码来源:Debug.php
示例15: actionLogin
public function actionLogin($id = 0)
{
if (isset($_POST['password'])) {
$pw = $_POST['password'];
$id = (int) $_POST['server_id'];
$server = Server::model()->findByPk((int) $id);
if (!$server) {
throw new CHttpException(404, Yii::t('mc', 'The requested page does not exist.'));
}
$this->net2FtpDefines();
global $net2ftp_result, $net2ftp_settings, $net2ftp_globals;
require_once dirname(__FILE__) . '/../extensions/net2ftp/main.inc.php';
require_once dirname(__FILE__) . '/../extensions/net2ftp/includes/authorizations.inc.php';
$ftpSv = $this->getFtpServer($server);
if (strlen($pw)) {
$_SESSION['net2ftp_password_encrypted'] = encryptPassword($pw);
$sessKey = 'net2ftp_password_encrypted_' . $ftpSv['ip'] . $this->getUsername($server);
unset($_SESSION[$sessKey]);
}
Yii::log('Logging in to FTP server for server ' . $id);
$this->redirect(array('ftpClient/browse', 'id' => $id));
}
$ftpUser = FtpUser::model()->findByAttributes(array('name' => Yii::app()->user->name));
$daemons = array();
$serverList = array();
$sel = Yii::t('mc', 'Please select a server');
if ($ftpUser) {
$c = new CDbCriteria();
$c->join = 'join `ftp_user_server` on `t`.`id`=`server_id`';
$c->condition = '`user_id`=? and `perms`!=\'\'';
$c->params = array((int) $ftpUser->id);
$svs = Server::model()->findAll($c);
$serverList = array(0 => Yii::t('mc', 'Select'));
foreach ($svs as $sv) {
$dmn = Daemon::model()->findByPk($sv->daemon_id);
$dmnInfo = array('ip' => '', 'port' => '');
if (!$dmn) {
$dmnInfo['ip'] = Yii::t('mc', 'No daemon found for this server.');
} else {
if (isset($dmn->ftp_ip) && isset($dmn->ftp_port)) {
$dmnInfo = array('ip' => $dmn->ftp_ip, 'port' => $dmn->ftp_port);
} else {
$dmnInfo['ip'] = Yii::t('mc', 'Daemon database not up to date, please run the Multicraft installer.');
}
}
$daemons[$sv->id] = $dmnInfo;
$serverList[$sv->id] = $sv->name;
}
} else {
$serverList = array(0 => Yii::t('mc', 'No FTP account found'));
$sel = Yii::t('mc', 'See the "Users" menu of your server for a list of FTP accounts');
}
$this->render('login', array('id' => $id, 'havePw' => isset($_SESSION['net2ftp_password_encrypted']), 'serverList' => $serverList, 'daemons' => $daemons, 'sel' => $sel));
}
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:54,代码来源:FtpClientController.php
示例16: init
/**
* Constructor.
* @return void
*/
public function init()
{
if ($this->isEnabled()) {
list($class, $name) = explode(':', $this->name . ':');
if (!class_exists($class)) {
Daemon::log($class . ' class not exists.');
return;
}
$this->pool = call_user_func(array($class, 'getInstance'), $name);
}
}
开发者ID:ruslanchek,项目名称:phpdaemon,代码行数:15,代码来源:Pool.php
示例17: init
public function init()
{
Daemon::addDefaultSettings(array('mod' . $this->modname . 'listen' => 'tcpstream://127.0.0.1:844', 'mod' . $this->modname . 'enable' => 0));
if (Daemon::$settings['mod' . $this->modname . 'enable']) {
Daemon::log(__CLASS__ . ' up.');
require_once Daemon::$dir . '/lib/asyncRTEPclient.class.php';
$this->client = new AsyncRTEPclient();
$this->client->addServer(Daemon::$settings[$k = 'mod' . $this->modname . 'addr']);
$this->client->trace = TRUE;
}
}
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:11,代码来源:RTEPClient.php
示例18: init
public function init()
{
Daemon::addDefaultSettings(array('mod' . $this->modname . 'dbname' => 'chat', 'mod' . $this->modname . 'adminpassword' => '', 'mod' . $this->modname . 'enable' => 0));
if (Daemon::$settings['mod' . $this->modname . 'enable']) {
Daemon::log(__CLASS__ . ' up.');
$this->db = Daemon::$appResolver->getInstanceByAppName('MongoClient');
$this->dbname =& Daemon::$settings[$k = 'mod' . $this->modname . 'dbname'];
$this->tags = array();
$this->minMsgInterval = 1;
}
}
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:11,代码来源:Chat.php
示例19: getConnection
public function getConnection($id)
{
if (@isset($this->connections[$id])) {
return $this->connections[$id];
}
$daemon = Daemon::model()->findByPk((int) $id);
if (!$daemon) {
return null;
}
$con = new McConnectionDemo($this, $id, $daemon->name, $daemon->ip, $daemon->port, '');
return $this->connections[$id] = $con;
}
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:12,代码来源:McBridgeDemo.php
示例20: onReady
/**
* Called when the worker is ready to go.
* @return void
*/
public function onReady()
{
$this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance();
/*$this->redis->eval("return {'a','b','c', {'d','e','f', {'g','h','i'}} }",0, function($redis) {
Daemon::log(Debug::dump($redis->result));
});*/
$this->redis->subscribe('te3st', function ($redis) {
Daemon::log(Debug::dump($redis->result));
});
$this->redis->psubscribe('test*', function ($redis) {
Daemon::log(Debug::dump($redis->result));
});
}
开发者ID:cobolbaby,项目名称:phpdaemon,代码行数:17,代码来源:Simple.php
注:本文中的Daemon类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论