/** * 投递任务 * * 和 swoole 不同的是, 它支持服务器集群下向任意集群去投递数据 * * @param $data * @param int $workerId * @param \Closure $callback * @param int $serverId 默认 -1 则优先本地投递 * @param string $serverGroup * @return bool|int */ public function task($data, $workerId = -1, $callback = null, $serverId = -1, $serverGroup = null) { if (Server::$clustersType < 2) { # 非高级集群模式 return $this->server->task($data, $workerId, $callback); } else { # 高级集群模式 $client = Clusters\Client::getClient($serverGroup, $serverId, $workerId, true); if (!$client) { $this->debug('get task client error'); return false; } return $client->sendData('task', $data, $this->name, $callback); } }
function task($task, $dstWorkerId = -1, $callback = null) { $this->server->task($task, $dstWorkerId = -1, $callback); }
function task($task, $dstWorkerId = -1) { $this->server->task($task, $dstWorkerId = -1); }