Skip to content

Commit

Permalink
Fix $symbol display in error message (Chikashi-Kato)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Eyrick authored Mar 17, 2018
2 parents 43d4edd + ba61ac4 commit 2e8e164
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions php-binance-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ public function depthCache($symbols, $callback) {
if ( !isset($this->depthQueue[$symbol]) ) $this->depthQueue[$symbol] = [];
if ( !isset($this->depthCache[$symbol]) ) $this->depthCache[$symbol] = ["bids" => [], "asks" => []];
$this->info[$symbol]['firstUpdate'] = 0;
$connector('wss://stream.binance.com:9443/ws/'.strtolower($symbol).'@depth')->then(function($ws) use($callback) {
$connector('wss://stream.binance.com:9443/ws/'.strtolower($symbol).'@depth')->then(function($ws) use($callback, $symbol) {
$ws->on('message', function($data) use($ws, $callback) {
$json = json_decode($data, true);
$symbol = $json['s'];
Expand All @@ -599,7 +599,7 @@ public function depthCache($symbols, $callback) {
$this->depthHandler($json);
call_user_func($callback, $this, $symbol, $this->depthCache[$symbol]);
});
$ws->on('close', function($code = null, $reason = null) {
$ws->on('close', function($code = null, $reason = null) use($symbol) {
echo "depthCache({$symbol}) WebSocket Connection closed! ({$code} - {$reason})".PHP_EOL;
});
}, function($e) use($loop) {
Expand All @@ -625,7 +625,7 @@ public function trades($symbols, $callback) {
foreach ( $symbols as $symbol ) {
if ( !isset($this->info[$symbol]) ) $this->info[$symbol] = [];
//$this->info[$symbol]['tradesCallback'] = $callback;
$connector('wss://stream.binance.com:9443/ws/'.strtolower($symbol).'@aggTrade')->then(function($ws) use($callback) {
$connector('wss://stream.binance.com:9443/ws/'.strtolower($symbol).'@aggTrade')->then(function($ws) use($callback, $symbol) {
$ws->on('message', function($data) use($ws, $callback) {
$json = json_decode($data, true);
$symbol = $json['s'];
Expand All @@ -637,7 +637,7 @@ public function trades($symbols, $callback) {
//$this->info[$symbol]['tradesCallback']($this, $symbol, $trades);
call_user_func($callback, $this, $symbol, $trades);
});
$ws->on('close', function($code = null, $reason = null) {
$ws->on('close', function($code = null, $reason = null) use($symbol) {
echo "trades({$symbol}) WebSocket Connection closed! ({$code} - {$reason})".PHP_EOL;
});
}, function($e) use($loop) {
Expand Down Expand Up @@ -687,7 +687,7 @@ public function chart($symbols, $interval = "30m", $callback) {
$this->chartQueue[$symbol][$interval] = [];
$this->info[$symbol][$interval]['firstOpen'] = 0;
//$this->info[$symbol]['chartCallback'.$interval] = $callback;
$connector('wss://stream.binance.com:9443/ws/'.strtolower($symbol).'@kline_'.$interval)->then(function($ws) use($callback) {
$connector('wss://stream.binance.com:9443/ws/'.strtolower($symbol).'@kline_'.$interval)->then(function($ws) use($callback, $symbol) {
$ws->on('message', function($data) use($ws, $callback) {
$json = json_decode($data);
$chart = $json->k;
Expand All @@ -697,7 +697,7 @@ public function chart($symbols, $interval = "30m", $callback) {
//$this->info[$symbol]['chartCallback'.$interval]($this, $symbol, $this->charts[$symbol][$interval]);
call_user_func($callback, $this, $symbol, $this->charts[$symbol][$interval]);
});
$ws->on('close', function($code = null, $reason = null) {
$ws->on('close', function($code = null, $reason = null) use($symbol) {
echo "chart({$symbol},{$interval}) WebSocket Connection closed! ({$code} - {$reason})".PHP_EOL;
});
}, function($e) use($loop) {
Expand Down

0 comments on commit 2e8e164

Please sign in to comment.