Skip to content

Commit

Permalink
private channel cannot be subscribed successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Jul 8, 2021
1 parent 783b56f commit d8ab0bc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
24 changes: 18 additions & 6 deletions src/Api/WebSocket/SocketClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ protected function getData($global,$callback=null,$sub=[]){
return $temp;
}

/*
*
* */
function reconPrivate(string $key){
$this->client->debug=[
'private'=>[$key=>'close'],
];
}

function reconPublic(){
$this->client->debug=[
'public'=>['market'=>'close','kline'=>'close'],
];
}


function test(){
print_r($this->client->all_sub);
print_r($this->client->add_sub);
Expand All @@ -207,14 +223,10 @@ function test2(){
}

function test_reconnection(){
$this->client->debug=[
'public'=>['market'=>'close','kline'=>'close'],
];
$this->reconPublic();
}

function test_reconnection2($key){
$this->client->debug=[
'private'=>[$key=>'close'],
];
$this->reconPrivate($key);
}
}
10 changes: 9 additions & 1 deletion src/Api/WebSocket/SocketServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,13 @@ private function debug($con,$global){
$debug['private'][$con->tag_keysecret['key']]='recon';
$global->save('debug',$debug);

//更改为掉线状态
$this->keysecretInit($con->tag_keysecret,[
'connection'=>2,
'connection_close'=>0,
'auth'=>0,
]);

$con->close();
}
}
Expand Down Expand Up @@ -402,7 +409,7 @@ private function subscribe($con,$global){

$temp_sub=[];
foreach ($temp['private'] as $v){
if($keysecret[$v[1]['key']]['auth']==0) continue;
if($keysecret[$v[1]['key']]['auth']!=1 || $keysecret[$v[1]['key']]['key']!=$con->tag_keysecret['key']) continue;

if($this->getPlatform()=='spot'){
$data=[
Expand All @@ -425,6 +432,7 @@ private function subscribe($con,$global){
$temp_sub[]=$v;
}


if(!empty($temp_sub)){
$global->addSubUpdate($temp_sub);
$global->allSubUpdate($temp_sub,'add');
Expand Down

0 comments on commit d8ab0bc

Please sign in to comment.