$tcp_worker = new Worker("tcp://0.0.0.0:2347");
$tcp_worker->count = 1;
$tcp_worker->onWorkerStart=function()
{
global $ws_worker;
$ws_worker = new Worker('text://0.0.0.0:5678');
$ws_worker->uidConnections = array();
$ws_worker->onMessage = "ws_message";
$ws_worker->onMessage = "ws_message";
$ws_worker->onClose = "ws_close";
$ws_worker->listen();
};
发生错误:
Worker process terminated
worker exit with status 64000
Exception: class \Protocols\Webscoket not exist in /var/www/gateway/Workerman-master/Worker.php:1976
http://doc.workerman.net/worker/listen.html 这里有例子,可以开一个进程监听两个端口,例如websocket端口和text端口,需要给车辆推送数据时和内部端口通讯完成推送。
如果是用的gatewayWorker,可以用gatewayClient给物联网设备推送数据,更简单一些。
http://doc.workerman.net/faq/push-in-other-project.html 这里是一些例子
谢谢!
我尝试了例子,working!
然而,我改了一下,我主worker是tcp,然后内部启动一个websocket worker,像这样:
发生错误:
是不是只能在内部用text协议?
对协议没限制