Skip to content

Commit

Permalink
upd WSConnectorAbstract
Browse files Browse the repository at this point in the history
close old connection before new and static for current node
  • Loading branch information
t3ran13 committed May 8, 2018
1 parent 298c304 commit 114075f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Connectors/WebSocket/WSConnectorAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class WSConnectorAbstract implements ConnectorInterface
*
* @var string
*/
private $currentNodeURL;
protected static $currentNodeURL;

/**
* waiting answer from Node during $wsTimeoutSeconds seconds
Expand Down Expand Up @@ -145,18 +145,18 @@ public function newConnection($nodeUrl)

public function getCurrentUrl()
{
if ($this->currentNodeURL === null) {
if (static::$currentNodeURL === null) {
if (is_array(static::$nodeURL)) {
$this->reserveNodeUrlList = static::$nodeURL;
$url = array_shift($this->reserveNodeUrlList);
} else {
$url = static::$nodeURL;
}

$this->currentNodeURL = $url;
static::$currentNodeURL = $url;
}

return $this->currentNodeURL;
return static::$currentNodeURL;
}

public function isExistReserveNodeUrl()
Expand All @@ -166,11 +166,13 @@ public function isExistReserveNodeUrl()

protected function setReserveNodeUrlToCurrentUrl()
{
$this->currentNodeURL = array_shift($this->reserveNodeUrlList);
static::$currentNodeURL = array_shift($this->reserveNodeUrlList);
}

public function connectToReserveNode()
{
$connection = $this->getConnection();
$connection->close();
$this->setReserveNodeUrlToCurrentUrl();
return $this->newConnection($this->getCurrentUrl());
}
Expand Down

0 comments on commit 114075f

Please sign in to comment.