swoole的websocket 部分怎么通知全部在线用户
2 回答
动漫人物
TA贡献1815条经验 获得超10个赞
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{
- 2 回答
- 0 关注
- 651 浏览
添加回答
举报
0/150
提交
取消