swoole的websocket 部分怎么通知全部在线用户
1 回答
慕尼黑5688855
TA贡献1848条经验 获得超2个赞
echo "server: handshake success with fd{$request->fd}\n";
$_SESSION['group'][$request->fd]=$request->fd;
});
$server->on('message', function (swoole_websocket_server $server, $frame) {
echo "receive from {$frame->fd}:{$frame->data},opcode:{$frame->opcode},fin:{$frame->finish}\n";
$arr=array_unique($_SESSION['group']);
$data=json_decode($frame->data,true);
if (is_array($arr)){
foreach ($arr as $key=>$row){
$server->push($row, json_encode(array('name'=>$data['name'],'type'=>$data['type'],'info'=>$data['info'])));
}
}else{
- 1 回答
- 0 关注
- 1457 浏览
添加回答
举报
0/150
提交
取消