|
2 | 2 |
|
3 | 3 | declare(strict_types=1); |
4 | 4 | /** |
5 | | - * This file is part of Hyperf. |
| 5 | + * This file is part of Simps. |
6 | 6 | * |
7 | | - * @link https://www.hyperf.io |
8 | | - * @document https://hyperf.wiki |
9 | | - |
10 | | - * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| 7 | + * @link https://simps.io |
| 8 | + * @document https://doc.simps.io |
| 9 | + * @license https://github.com/simple-swoole/simps/blob/master/LICENSE |
11 | 10 | */ |
12 | 11 | namespace Simps\RpcMultiplex; |
13 | 12 |
|
|
22 | 21 |
|
23 | 22 | class TcpServer |
24 | 23 | { |
| 24 | + public static $incr = 0; |
| 25 | + |
25 | 26 | /** |
26 | 27 | * @var Server |
27 | 28 | */ |
@@ -67,7 +68,7 @@ public function __construct() |
67 | 68 | $this->_server->on('workerStart', [$this, 'onWorkerStart']); |
68 | 69 | $this->_server->on('receive', [$this, 'onReceive']); |
69 | 70 |
|
70 | | - foreach ($wsConfig['callbacks'] as $eventKey => $callbackItem) { |
| 71 | + foreach ($wsConfig['callbacks'] ?? [] as $eventKey => $callbackItem) { |
71 | 72 | [$class, $func] = $callbackItem; |
72 | 73 | $this->_server->on($eventKey, [$class, $func]); |
73 | 74 | } |
@@ -112,8 +113,8 @@ public function onReceive(Server $server, int $fd, int $fromId, string $data) |
112 | 113 | $class = $protocol->getClass(); |
113 | 114 | $method = $protocol->getMethod(); |
114 | 115 | $params = $protocol->getParams(); |
115 | | - $protocol->setResult((new $class())->{$method}(...$params)); |
116 | | - $result = serialize($protocol); |
| 116 | + |
| 117 | + $result = serialize($protocol->setResult((new $class())->{$method}(...$params))); |
117 | 118 | } catch (\Throwable $exception) { |
118 | 119 | $result = serialize($protocol->setError($exception->getCode(), $exception->getMessage())); |
119 | 120 | } finally { |
|
0 commit comments