MqttListener.php 751 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace App\Listener;
  12. use Hyperf\Event\Annotation\Listener;
  13. use Hyperf\Event\Contract\ListenerInterface;
  14. use Nashgao\MQTT\Event\OnReceiveEvent;
  15. /**
  16. * mqtt 信号处理器
  17. */
  18. #[Listener]
  19. class MqttListener implements ListenerInterface
  20. {
  21. public function listen(): array
  22. {
  23. return [
  24. OnReceiveEvent::class,
  25. ];
  26. }
  27. /**
  28. * @param OnReceiveEvent $event
  29. * @return void
  30. */
  31. public function process($event): void
  32. {
  33. dd($event->message);
  34. }
  35. }