Skip to content

Commit

Permalink
add coin future private subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Nov 4, 2020
1 parent edc3b7d commit df75e0a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ $binance->getSubscribe([
},true);
```

获取私有频道订阅数据,
获取私有频道订阅数据,私有频道默认全部返回
```php
//The first way
$binance->keysecret($key_secret);
Expand Down
3 changes: 0 additions & 3 deletions src/Api/WebSocket/SocketClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ protected function init(){

function keysecret(array $keysecret=[]){
$this->keysecret=$keysecret;

$this->keysecretInit($this->keysecret);

return $this;
}

Expand Down
25 changes: 23 additions & 2 deletions src/Api/WebSocket/SocketServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ private function onMessage($global){
return;
}

//if($con->tag!='public')

if(isset($data['e']) && $con->tag!='public') {
$table=$this->userKey($con->tag_keysecret,$data['e']);

Expand All @@ -116,6 +114,8 @@ private function onMessage($global){
return;
}

if(isset($data['result']) && empty($data['result'])) return;

$this->log($data);
};
}
Expand Down Expand Up @@ -166,6 +166,8 @@ private function other($con,$global){

$this->account($con,$global);

$this->coinFutureSubscribe($con,$global);

$this->log('listen '.$con->tag);
});
}
Expand Down Expand Up @@ -295,4 +297,23 @@ private function account($con,$global){

}
}

/**
* @param $con
* @param $global
*/
private function coinFutureSubscribe($con,$global){
if($con->tag!='public' && $this->config['baseurl']=='ws://dstream.binance.com'){
$data=[
"method"=>"REQUEST",
'params'=>[
'@account',
'@balance',
'@position',
],
'id'=>$this->getId()
];
$con->send(json_encode($data));
}
}
}
7 changes: 2 additions & 5 deletions tests/websocket/client_coin_future.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,8 @@
case 10:{
$binance->keysecret($key_secret[2]);
//Subscribe to all private channels by default
$binance->subscribe([
'@account',
'@balance',
'@position',
]);
$binance->subscribe();

break;
}

Expand Down

0 comments on commit df75e0a

Please sign in to comment.