当前位置: 首页>>代码示例>>PHP>>正文


PHP Worker::runAll方法代码示例

本文整理汇总了PHP中Workerman\Worker::runAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Worker::runAll方法的具体用法?PHP Worker::runAll怎么用?PHP Worker::runAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Workerman\Worker的用法示例。


在下文中一共展示了Worker::runAll方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: startAction

 public function startAction()
 {
     $worker = new Worker('tcp://0.0.0.0:1234');
     $worker->count = 2;
     $worker->onMessage = array($this, 'onMessage');
     $worker->onConnect = array($this, 'onConnect');
     $worker->onWorkerStart = array($this, 'onWorkerStart');
     $worker->runAll();
 }
开发者ID:jixm,项目名称:Simple-PHP-MVC-Skeleton,代码行数:9,代码来源:Walkman.php

示例2: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     global $argv;
     $argv[0] = 'artisan';
     $argv[1] = 'reload';
     Worker::runAll();
 }
开发者ID:Hehe-Zhc,项目名称:workerboy,代码行数:13,代码来源:ReloadCommand.php

示例3: runAll

 public static function runAll($AppName = null)
 {
     self::$AppName = $AppName ?: "workerman";
     static::$logFile = self::workermanTempFile(self::FILE_TYPE_LOG);
     static::$pidFile = self::workermanTempFile(self::FILE_TYPE_PID);
     static::$stdoutFile = self::workermanTempFile(self::FILE_TYPE_STDOUT);
     parent::runAll();
 }
开发者ID:impress-php,项目名称:framework,代码行数:8,代码来源:Worker.php

示例4: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $deamonMode = $this->option('deamon');
     global $argv;
     $argv[0] = 'artisan';
     $argv[1] = 'restart';
     $argv[2] = $deamonMode ? '-d' : null;
     Worker::runAll();
 }
开发者ID:Hehe-Zhc,项目名称:workerboy,代码行数:15,代码来源:RestartCommand.php

示例5: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $ws_worker = new Worker("websocket://0.0.0.0:2346");
     $ws_worker->onConnect = function ($connection) {
         echo "New connection\n";
     };
     $ws_worker->onMessage = function (TcpConnection $connection, $data) {
         // 转发数据给所有客户端
         foreach ($connection->worker->connections as $connection) {
             /** @var TcpConnection $connection */
             $connection->send($data);
         }
     };
     $ws_worker->onClose = function ($connection) {
         echo "Connection closed\n";
     };
     // Hack Run worker
     global $argv;
     $argv = [null, 'start'];
     $ws_worker->runAll();
 }
开发者ID:shellus,项目名称:laravel_worker,代码行数:26,代码来源:WsServerStart.php

示例6: function

$gateway->count = 4;
// 分布式部署时请设置成内网ip(非127.0.0.1)
$gateway->lanIp = '127.0.0.1';
// 内部通讯起始端口,假如$gateway->count=4,起始端口为4000
// 则一般会使用4001 4002 4003 4004 4个端口作为内部通讯端口
$gateway->startPort = 3000;
// 心跳间隔
$gateway->pingInterval = 10;
// 心跳数据
$gateway->pingData = '{"type":"ping"}';
/* 上线时 为了安全 开启
// 当客户端连接上来时,设置连接的onWebSocketConnect,即在websocket握手时的回调
$gateway->onConnect = function($connection)
{
    $connection->onWebSocketConnect = function($connection , $http_header)
    {
        // 可以在这里判断连接来源是否合法,不合法就关掉连接
        // $_SERVER['HTTP_ORIGIN']标识来自哪个站点的页面发起的websocket链接
        if($_SERVER['HTTP_ORIGIN'] != 'http://chat.zhbor.com')
        {
            $connection->close();
        }
        // onWebSocketConnect 里面$_GET $_SERVER是可用的
        // var_dump($_GET, $_SERVER);
    };
}; 
*/
// 如果不是在根目录启动,则运行runAll方法
if (!defined('GLOBAL_START')) {
    Worker::runAll();
}
开发者ID:hongbo819,项目名称:webChat,代码行数:31,代码来源:start_gateway.php

示例7: start

 /**
  * 启动服务器
  * @return void
  */
 public function start()
 {
     if ($this->isStart) {
         return;
     }
     $this->isStart = true;
     Worker::runAll();
 }
开发者ID:yb199478,项目名称:framework,代码行数:12,代码来源:WorkermanServer.php

示例8: start

 /**
  * start server
  *
  */
 public function start()
 {
     Worker::runAll();
 }
开发者ID:nirgendswo,项目名称:justText,代码行数:8,代码来源:Server.php

示例9: Worker

<?php

/**
 * WebSocket Server.
 */
require_once 'vendor/autoload.php';
use Workerman\Worker;
$websocketServer = new Worker('websocket://127.0.0.1:8080');
$websocketServer->onConnect = function ($connection) {
    $data = json_encode(['time' => time(), 'message' => 'Merhaba!']);
    $connection->send($data);
};
$websocketServer->onMessage = function ($connection, $data) {
    $data = json_encode(['time' => time(), 'message' => htmlspecialchars($data, ENT_NOQUOTES | ENT_HTML5, 'UTF-8')]);
    $connection->send($data);
};
$websocketServer->onClose = function ($connection) {
};
$websocketServer->runAll();
开发者ID:hdogan,项目名称:phpkonf-2015-demos,代码行数:19,代码来源:websocket.php

示例10: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $deamonMode = $this->option('deamon');
     // 检查扩展
     if (!extension_loaded('pcntl')) {
         $this->error("Please install pcntl extension. See http://doc3.workerman.net/install/install.html\n");
         return;
     }
     if (!extension_loaded('posix')) {
         $this->error("Please install posix extension. See http://doc3.workerman.net/install/install.html\n");
         return;
     }
     // 标记是全局启动
     define('GLOBAL_START', 1);
     $applications = Config::get('workerboy.applications');
     // 加载所有Applications/*/start.php,以便启动所有服务
     foreach ($applications as $application => $config) {
         $startPath = base_path($application);
         if (is_file($startPath)) {
             require_once $startPath;
         }
     }
     // 运行所有服务
     global $argv;
     $argv[0] = 'artisan';
     $argv[1] = 'start';
     $argv[2] = $deamonMode ? '-d' : null;
     Worker::runAll();
 }
开发者ID:Hehe-Zhc,项目名称:workerboy,代码行数:35,代码来源:StartCommand.php


注:本文中的Workerman\Worker::runAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。