VERSION
VERSION = '3.0.12' : string
版本
Gateway,基于Worker 开发 用于转发客户端的数据给Worker处理,以及转发Worker的数据给客户端
$globalEvent : \Workerman\Events\EventInterface
Global event loop.
$_workers : array<mixed,\Workerman\Worker>
All worker instances.
$_innerTcpWorker : \Workerman\Worker
gateway 内部监听 worker 内部连接的 worker
getEventLoop() : \Workerman\Events\EventInterface
Get global event-loop instance.
onClientMessage(\Workerman\Connection\TcpConnection $connection, mixed $data)
当客户端发来数据时,转发给worker处理
\Workerman\Connection\TcpConnection | $connection | |
mixed | $data |
onClientConnect(\Workerman\Connection\TcpConnection $connection)
当客户端连接上来时,初始化一些客户端的数据 包括全局唯一的client_id、初始化session等
\Workerman\Connection\TcpConnection | $connection |
routerRand(array $worker_connections, \Workerman\Connection\TcpConnection $client_connection, integer $cmd, mixed $buffer) : \Workerman\Connection\TcpConnection
随机路由,返回 worker connection 对象
array | $worker_connections | |
\Workerman\Connection\TcpConnection | $client_connection | |
integer | $cmd | |
mixed | $buffer |
routerBind(array $worker_connections, \Workerman\Connection\TcpConnection $client_connection, integer $cmd, mixed $buffer) : \Workerman\Connection\TcpConnection
client_id 与 worker 绑定
array | $worker_connections | |
\Workerman\Connection\TcpConnection | $client_connection | |
integer | $cmd | |
mixed | $buffer |
onClientClose(\Workerman\Connection\TcpConnection $connection)
当客户端关闭时
\Workerman\Connection\TcpConnection | $connection |
onWorkerConnect(\Workerman\Connection\TcpConnection $connection)
当 worker 通过内部通讯端口连接到 gateway 时
\Workerman\Connection\TcpConnection | $connection |
onWorkerMessage(\Workerman\Connection\TcpConnection $connection, mixed $data) : void
当 worker 发来数据时
\Workerman\Connection\TcpConnection | $connection | |
mixed | $data |
onWorkerClose(\Workerman\Connection\TcpConnection $connection)
当worker连接关闭时
\Workerman\Connection\TcpConnection | $connection |
forkOneWorkerForLinux(\Workerman\Worker $worker)
Fork one worker process.
\Workerman\Worker | $worker |
sendToWorker(integer $cmd, \Workerman\Connection\TcpConnection $connection, mixed $body = '') : boolean
发送数据给 worker 进程
integer | $cmd | |
\Workerman\Connection\TcpConnection | $connection | |
mixed | $body |