手冊中寫的是
返回值
返回 $worker_connnections 中的一個連接對象。如果沒有可返回的$worker_connnections,則返回false。
然后我這樣寫return false;
最終報錯了竟然
PHP Fatal error: Call to a member function send() on boolean in /share/gatewayworker/vendor/workerman/gateway-worker/src/Gateway.php on line 414
Fatal error: Call to a member function send() on boolean in /share/gatewayworker/vendor/workerman/gateway-worker/src/Gateway.php on line 414
Worker[21969] process terminated with ERROR: E_ERROR "Call to a member function send() on boolean in /share/gatewayworker/vendor/workerman/gateway-worker/src/Gateway.php on line 414"
看了源碼好像是沒有對返回的worker_connection錯判斷
$worker_connection = call_user_func($this->router, $this->_workerConnections, $connection, $cmd, $body);
if (false === $worker_connection->send($gateway_data)) {
$msg = "SendBufferToWorker fail. May be the send buffer are overflow. See http://doc2.workerman.net/send-buffer-overflow.html";
static::log($msg);
return false;
}
必須返回一個連接對象
實(shí)際場景,2個gateway監(jiān)聽不同類型協(xié)議的端口,想用這個路由功能導(dǎo)向不同的BusinessWorker中處理,但如何將無法分流的數(shù)導(dǎo)向默認(rèn)BusinessWorker或者干脆干掉?