ClientService.php 885 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\JsonRpc;
  3. use Hyperf\RpcServer\Annotation\RpcService;
  4. use App\Tools\Result;
  5. #[RpcService(name: "ClientService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
  6. class ClientService implements ClientServiceInterface
  7. {
  8. /**
  9. * @param array $data
  10. * @return array
  11. */
  12. public function test(array $data): array
  13. {
  14. \Hyperf\Utils\ApplicationContext::getContainer()
  15. ->get(\Hyperf\Logger\LoggerFactory::class)
  16. ->get('log')->info('RPC调用到达', $data);
  17. var_dump($data, '---------------');
  18. $time = date('Y-m-d H:i:s', time());
  19. $data = [
  20. 'code' => 200,
  21. 'msg' => 'success',
  22. 'data' => [
  23. 'time' => $time,
  24. 'data' => $data,
  25. ]
  26. ];
  27. return ['code' => 200, 'msg' => 'success', 'data' => $data];
  28. }
  29. }