123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\JsonRpc;
- use Hyperf\RpcClient\AbstractServiceClient;
- use Hyperf\Logger\LoggerFactory;
- use Psr\Log\LoggerInterface;
- class ClientService extends AbstractServiceClient implements ClientServiceInterface
- {
- /**
- * 定义对应服务提供者的服务名称
- * @var string
- */
- protected string $serviceName = 'ClientService';
- /**
- * 定义对应服务提供者的服务协议
- * @var string
- */
- protected string $protocol = 'jsonrpc-http';
- protected $logger;
- public function __construct(LoggerFactory $loggerFactory)
- {
- $this->logger = $loggerFactory->get('default');
- }
- /**
- * test
- * @param array $data
- * @return array
- */
- public function test(array $data): array
- {
- var_dump($data, $this->serviceName, $this->protocol);
- $this->logger->info('请求数据: ' . json_encode($data));
- return $this->__request(__FUNCTION__, $data);
- }
- }
|