Skip to content

Commit 114075f

Browse files
committed
upd WSConnectorAbstract
close old connection before new and static for current node
1 parent 298c304 commit 114075f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Connectors/WebSocket/WSConnectorAbstract.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract class WSConnectorAbstract implements ConnectorInterface
3737
*
3838
* @var string
3939
*/
40-
private $currentNodeURL;
40+
protected static $currentNodeURL;
4141

4242
/**
4343
* waiting answer from Node during $wsTimeoutSeconds seconds
@@ -145,18 +145,18 @@ public function newConnection($nodeUrl)
145145

146146
public function getCurrentUrl()
147147
{
148-
if ($this->currentNodeURL === null) {
148+
if (static::$currentNodeURL === null) {
149149
if (is_array(static::$nodeURL)) {
150150
$this->reserveNodeUrlList = static::$nodeURL;
151151
$url = array_shift($this->reserveNodeUrlList);
152152
} else {
153153
$url = static::$nodeURL;
154154
}
155155

156-
$this->currentNodeURL = $url;
156+
static::$currentNodeURL = $url;
157157
}
158158

159-
return $this->currentNodeURL;
159+
return static::$currentNodeURL;
160160
}
161161

162162
public function isExistReserveNodeUrl()
@@ -166,11 +166,13 @@ public function isExistReserveNodeUrl()
166166

167167
protected function setReserveNodeUrlToCurrentUrl()
168168
{
169-
$this->currentNodeURL = array_shift($this->reserveNodeUrlList);
169+
static::$currentNodeURL = array_shift($this->reserveNodeUrlList);
170170
}
171171

172172
public function connectToReserveNode()
173173
{
174+
$connection = $this->getConnection();
175+
$connection->close();
174176
$this->setReserveNodeUrlToCurrentUrl();
175177
return $this->newConnection($this->getCurrentUrl());
176178
}

0 commit comments

Comments
 (0)