workerman一个实例worker2(自定义协议)用来与设备通信,另一个实例worker1(websocker)用来与前端页面通信,通过前端页面给worker2指令,并将worker2收到的数据表现在前端页面worker1 = new Worker("Websocket://0.0.0.0:23456");
$worker2 = new Worker("tcp://0.0.0.0:5555");
// 启动1个进程对外提供服务$worker1->count = 1;
$worker2->count = 1;
// 当客户端发来数据时
$worker1->onMessage = function($connection,$data)
{
// 向客户端发送hello $data
echo $data;
};
$worker2->onMessage = function($connection, $data){
// 向客户端发送hello $data
echo $data;
};
// 当有客户端连接上服务器
$worker1->onConnect = function($connection