Skip to content

Commit

Permalink
unsubscribe all
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Aug 20, 2024
1 parent f92cd85 commit 5511b10
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/Api/WebSocketV5/SocketServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,14 @@ private function unsubscribe($con,$global){
];

$temp=$global->get('del_sub');
foreach ($temp as $v){
if(array_key_exists('key',$v)) {
unset($v['key']);
$sub['private'][]=$v;
}
else $sub['public'][]=$v;
}

if($con->tag=='public'){

foreach ($temp as $v){
if(!array_key_exists('key',$v)) $sub['public'][]=$v;
}
if(empty($sub['public'])) return;

$data=[
'op' => "unsubscribe",
'args' => $sub['public'],
Expand All @@ -397,13 +396,25 @@ private function unsubscribe($con,$global){
//*******订阅成功后 更改 all_sub public 值
$global->unAllSubUpdate('public',['sub'=>$sub['public']]);
}else{
//获取当前用户
$keysecret=$con->tag_keysecret;

//判断private取消订阅是当前用户
foreach ($temp as $v){
if(array_key_exists('key',$v)) {
if($keysecret['key']!==$v['key']) return;
unset($v['key']);

$sub['private'][]=$v;//TODO 有BUG 全部私有数据
}
}

$data=[
'op' => "unsubscribe",
'args' => $sub['private'],
];

//print_r($temp);
//print_r($data);
$data=json_encode($data);
$con->send($data);

Expand Down

0 comments on commit 5511b10

Please sign in to comment.