亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

swoole的websocket 部分怎么通知全部在線用戶?

swoole的websocket 部分怎么通知全部在線用戶?

UYOU 2018-10-22 09:05:53
swoole的websocket 部分怎么通知全部在線用戶
查看完整描述

1 回答

?
喵喔喔

TA貢獻1735條經驗 獲得超5個贊

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{

查看完整回答
反對 回復 2018-11-15
  • 1 回答
  • 0 關注
  • 846 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號