猿问

swoole的websocket 部分怎么通知全部在线用户?

swoole的websocket 部分怎么通知全部在线用户


UYOU
浏览 805回答 1
1回答

喵喔喔

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{
随时随地看视频慕课网APP
我要回答