ParserInterface.php 535 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace think\swoole\contract\websocket;
  3. use Swoole\WebSocket\Frame;
  4. interface ParserInterface
  5. {
  6. /**
  7. * Encode output payload for websocket push.
  8. *
  9. * @param string $event
  10. * @param mixed $data
  11. *
  12. * @return mixed
  13. */
  14. public function encode(string $event, $data);
  15. /**
  16. * Input message on websocket connected.
  17. * Define and return event name and payload data here.
  18. *
  19. * @param Frame $frame
  20. *
  21. * @return array
  22. */
  23. public function decode($frame);
  24. }