@@ -201,7 +201,7 @@ |
||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | - * @param $id |
|
| 204 | + * @param string $id |
|
| 205 | 205 | * @return bool |
| 206 | 206 | */ |
| 207 | 207 | public function registerHeartbeat($id) |
@@ -239,7 +239,7 @@ |
||
| 239 | 239 | public function resetNow() |
| 240 | 240 | { |
| 241 | 241 | $this->now = function() { |
| 242 | - return round(microtime(true)*1000); |
|
| 242 | + return round(microtime(true) * 1000); |
|
| 243 | 243 | }; |
| 244 | 244 | } |
| 245 | 245 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | /** |
| 382 | 382 | * @param string $id |
| 383 | 383 | * @param string $type |
| 384 | - * @return string[] |
|
| 384 | + * @return string |
|
| 385 | 385 | */ |
| 386 | 386 | protected function prepareBinderMessage($id, $type) |
| 387 | 387 | { |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | /** |
| 392 | 392 | * @param string $id |
| 393 | 393 | * @param string $type |
| 394 | - * @return string[] |
|
| 394 | + * @return string |
|
| 395 | 395 | */ |
| 396 | 396 | protected function prepareConnectorMessage($id, $type) |
| 397 | 397 | { |
@@ -591,6 +591,7 @@ discard block |
||
| 591 | 591 | /** |
| 592 | 592 | * @param Connection $conn |
| 593 | 593 | * @param $message[] |
| 594 | + * @param string[] $message |
|
| 594 | 595 | * @return mixed |
| 595 | 596 | */ |
| 596 | 597 | private function recvMessage(Connection $conn, $message) |
@@ -754,7 +755,7 @@ discard block |
||
| 754 | 755 | * @param string $type |
| 755 | 756 | * @param string|string[] $message |
| 756 | 757 | * @param int $flags |
| 757 | - * @return bool |
|
| 758 | + * @return integer |
|
| 758 | 759 | */ |
| 759 | 760 | private function sendMessage($id, $type, $message = null, $flags = Channel::MODE_STANDARD) |
| 760 | 761 | { |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | ]; |
| 137 | 137 | |
| 138 | 138 | $options = [ |
| 139 | - 'bufferSize' => isset($params['bufferSize']) ? (int)$params['bufferSize'] : 0, |
|
| 140 | - 'bufferTimeout' => isset($params['bufferTimeout']) ? (int)$params['bufferTimeout'] : 0, |
|
| 141 | - 'heartbeatInterval' => isset($params['heartbeatInterval']) ? (int)$params['heartbeatInterval'] : 200, |
|
| 142 | - 'heartbeatKeepalive' => isset($params['heartbeatKeepalive']) ? (int)$params['heartbeatKeepalive'] : 1000, |
|
| 143 | - 'timeRegisterInterval' => isset($params['timeRegisterInterval']) ? (int)$params['timeRegisterInterval'] : 400 |
|
| 139 | + 'bufferSize' => isset($params['bufferSize']) ? (int) $params['bufferSize'] : 0, |
|
| 140 | + 'bufferTimeout' => isset($params['bufferTimeout']) ? (int) $params['bufferTimeout'] : 0, |
|
| 141 | + 'heartbeatInterval' => isset($params['heartbeatInterval']) ? (int) $params['heartbeatInterval'] : 200, |
|
| 142 | + 'heartbeatKeepalive' => isset($params['heartbeatKeepalive']) ? (int) $params['heartbeatKeepalive'] : 1000, |
|
| 143 | + 'timeRegisterInterval' => isset($params['timeRegisterInterval']) ? (int) $params['timeRegisterInterval'] : 400 |
|
| 144 | 144 | ]; |
| 145 | 145 | |
| 146 | 146 | $this->loop = $loop; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | if (!$this->startConnection()) |
| 201 | 201 | { |
| 202 | - $this->emit('error', [ new ExecutionException('socket not connected.') ]); |
|
| 202 | + $this->emit('error', [new ExecutionException('socket not connected.')]); |
|
| 203 | 203 | return false; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | if (!$this->stopConnection()) |
| 242 | 242 | { |
| 243 | - $this->emit('error', [ new ExecutionException('socket not disconnected.') ]); |
|
| 243 | + $this->emit('error', [new ExecutionException('socket not disconnected.')]); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $this->isConnected = false; |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | if ($status === static::SEND_STATUS_SUCCEEDED) |
| 265 | 265 | { |
| 266 | - $this->emit('send', [ $id, (array) $message ]); |
|
| 266 | + $this->emit('send', [$id, (array) $message]); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | return $status > 0; |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | foreach ($conns as $conn) |
| 287 | 287 | { |
| 288 | - $this->emit('send', [ $conn, (array) $message ]); |
|
| 288 | + $this->emit('send', [$conn, (array) $message]); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | return $statuses; |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | $type = $multipart[2]; |
| 361 | 361 | $message = $multipart[3]; |
| 362 | 362 | |
| 363 | - return [ $id, $type, $message ]; |
|
| 363 | + return [$id, $type, $message]; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | /** |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $type = $multipart[2]; |
| 376 | 376 | $message = $multipart[3]; |
| 377 | 377 | |
| 378 | - return [ $id, $type, $message ]; |
|
| 378 | + return [$id, $type, $message]; |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | |
| 564 | 564 | switch ($type) |
| 565 | 565 | { |
| 566 | - case self::COMMAND_HEARTBEAT: $this->onRecvHeartbeat($conn); break; |
|
| 566 | + case self::COMMAND_HEARTBEAT: $this->onRecvHeartbeat($conn); break; |
|
| 567 | 567 | case self::COMMAND_MESSAGE: $this->onRecvMessage($conn, $message); break; |
| 568 | 568 | default: return; |
| 569 | 569 | } |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | */ |
| 596 | 596 | private function recvMessage(Connection $conn, $message) |
| 597 | 597 | { |
| 598 | - $this->emit('recv', [ $conn->id, $message ]); |
|
| 598 | + $this->emit('recv', [$conn->id, $message]); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | |
| 611 | 611 | if ($this->connectionPool->setConnection($conn)) |
| 612 | 612 | { |
| 613 | - $this->emit('connect', [ $conn->id ]); |
|
| 613 | + $this->emit('connect', [$conn->id]); |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | if ($this->type === Channel::BINDER) |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | switch ($this->type) |
| 687 | 687 | { |
| 688 | 688 | case Channel::CONNECTOR: $this->destroyConnector(); break; |
| 689 | - case Channel::BINDER: $this->destroyBinder(); break; |
|
| 689 | + case Channel::BINDER: $this->destroyBinder(); break; |
|
| 690 | 690 | default: return false; |
| 691 | 691 | } |
| 692 | 692 | } |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | $this->clearConnectionPool(); |
| 858 | 858 | |
| 859 | 859 | $proxy = $this; |
| 860 | - $this->hTimer = $this->loop->addPeriodicTimer(($this->options['heartbeatInterval']/1000), function() use($proxy) { |
|
| 860 | + $this->hTimer = $this->loop->addPeriodicTimer(($this->options['heartbeatInterval'] / 1000), function() use($proxy) { |
|
| 861 | 861 | |
| 862 | 862 | if ($proxy->type === Channel::CONNECTOR) |
| 863 | 863 | { |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | |
| 894 | 894 | foreach ($deleted as $deletedid) |
| 895 | 895 | { |
| 896 | - $this->emit('disconnect', [ $deletedid ]); |
|
| 896 | + $this->emit('disconnect', [$deletedid]); |
|
| 897 | 897 | } |
| 898 | 898 | } |
| 899 | 899 | |
@@ -908,8 +908,8 @@ discard block |
||
| 908 | 908 | if ($this->rTimer === null && $this->flags['enableHeartbeat'] === true && $this->flags['enableTimeRegister'] === true) |
| 909 | 909 | { |
| 910 | 910 | $proxy = $this; |
| 911 | - $this->rTimer = $this->loop->addPeriodicTimer(($this->options['timeRegisterInterval']/1000), function() use($proxy) { |
|
| 912 | - $now = round(microtime(true)*1000); |
|
| 911 | + $this->rTimer = $this->loop->addPeriodicTimer(($this->options['timeRegisterInterval'] / 1000), function() use($proxy) { |
|
| 912 | + $now = round(microtime(true) * 1000); |
|
| 913 | 913 | $proxy->connectionPool->setNow(function() use($now) { |
| 914 | 914 | return $now; |
| 915 | 915 | }); |
@@ -654,9 +654,11 @@ discard block |
||
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | 656 | catch (Error $ex) |
| 657 | - {} |
|
| 657 | + { |
|
| 658 | +} |
|
| 658 | 659 | catch (Exception $ex) |
| 659 | - {} |
|
| 660 | + { |
|
| 661 | +} |
|
| 660 | 662 | |
| 661 | 663 | if ($ex !== null) |
| 662 | 664 | { |
@@ -691,9 +693,11 @@ discard block |
||
| 691 | 693 | } |
| 692 | 694 | } |
| 693 | 695 | catch (Error $ex) |
| 694 | - {} |
|
| 696 | + { |
|
| 697 | +} |
|
| 695 | 698 | catch (Exception $ex) |
| 696 | - {} |
|
| 699 | + { |
|
| 700 | +} |
|
| 697 | 701 | |
| 698 | 702 | if ($ex !== null) |
| 699 | 703 | { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | foreach ($buffer as $message) |
| 80 | 80 | { |
| 81 | - $messages[] = [ $id, $message ]; |
|
| 81 | + $messages[] = [$id, $message]; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $this->messageBuffer[$id] = []; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | foreach ($this->messageBuffer[$id] as $message) |
| 95 | 95 | { |
| 96 | - $messages[] = [ $id, $message ]; |
|
| 96 | + $messages[] = [$id, $message]; |
|
| 97 | 97 | $cnt++; |
| 98 | 98 | } |
| 99 | 99 | |