Skip to content

Commit

Permalink
Improved WebSocketClient.
Browse files Browse the repository at this point in the history
  • Loading branch information
andot committed Nov 17, 2016
1 parent 1cc155d commit 028331e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Hprose/Swoole/WebSocket/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* *
* hprose swoole websocket client library for php 5.3+ *
* *
* LastModified: Aug 6, 2016 *
* LastModified: Nov 18, 2016 *
* Author: Ma Bingyao <[email protected]> *
* *
\**********************************************************/
Expand Down Expand Up @@ -210,11 +210,7 @@ private function connect() {
});
}
protected function sendAndReceive($request, stdClass $context) {
if (!$this->connecting && ($this->ws === null || !$this->ws->isConnected())) {
$this->connect();
}
$future = new Future();
$ws = $this->ws;
$id = $this->getNextId();
$count = &$this->count;
$futures = &$this->futures;
Expand All @@ -236,6 +232,10 @@ protected function sendAndReceive($request, stdClass $context) {
});

}
if (!$this->connecting && ($this->ws === null || !$this->ws->isConnected())) {
$this->connect();
}
$ws = $this->ws;
if ($count < 100) {
++$count;
$this->ready->then(function() use ($ws, $id, $request, &$futures) {
Expand Down

0 comments on commit 028331e

Please sign in to comment.