This commit is contained in:
2021-10-28 15:40:50 +08:00
parent 0f3e1481bb
commit 642e16a07c
+4 -2
View File
@@ -4,9 +4,8 @@ namespace Kiri\Rpc;
use Exception; use Exception;
use Kiri\Consul\Catalog\Catalog;
use Kiri\Context; use Kiri\Context;
use Kiri\Kiri; use Kiri\Core\Number;
use Kiri\Pool\Pool; use Kiri\Pool\Pool;
use Swoole\Client; use Swoole\Client;
use Swoole\Coroutine; use Swoole\Coroutine;
@@ -61,6 +60,9 @@ abstract class JsonRpcConsumers implements OnRpcConsumerInterface
} else { } else {
$client = $this->clientNotCoroutine($config); $client = $this->clientNotCoroutine($config);
} }
if (empty($id)) $id = Number::create(time());
$client->send(json_encode(['jsonrpc' => $version, 'service' => $service, 'method' => $method, 'params' => $data, 'id' => $id])); $client->send(json_encode(['jsonrpc' => $version, 'service' => $service, 'method' => $method, 'params' => $data, 'id' => $id]));
$read = $client->recv(); $read = $client->recv();
$client->close(); $client->close();