Gateway/Worker小问题

crh5354

是不是把start.php写成下面这样

<?php 
use \Workerman\Worker;
use \Workerman\WebServer;
use \GatewayWorker\Gateway;
use \GatewayWorker\BusinessWorker;
use \Workerman\Autoloader;

// 自动加载类
require_once __DIR__ . '/../../Workerman/Autoloader.php';
Autoloader::setRootPath(__DIR__);

// gateway 进程
$gateway = new Gateway("Websocket://0.0.0.0:7272");
$gateway->name = 'ZooGateway';
$gateway->count = 4;
$gateway->lanIp = '127.0.0.1';
$gateway->startPort = 3000;
$gateway->pingInterval = 10;
$gateway->pingData = '{"type":"ping"}';

// bussinessWorker 进程
$worker = new BusinessWorker();
// worker名称
$worker->name = 'TodpoleBusinessWorker';
// bussinessWorker进程数量
$worker->count = 4;

if(!defined('GLOBAL_START'))
{
    Worker::runAll();
}

然后Event.php就可以写业务了,Gateway/Worker它们自己会连接起来了嘛?

3769 1 0
1个回答

walkor 打赏

  • 暂无评论
年代过于久远,无法发表回答
×
🔝