Event.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 Hyperf\Server;
  12. class Event
  13. {
  14. /**
  15. * Swoole onStart event.
  16. */
  17. public const ON_START = 'start';
  18. /**
  19. * Swoole onWorkerStart event.
  20. */
  21. public const ON_WORKER_START = 'workerStart';
  22. /**
  23. * Swoole onWorkerStop event.
  24. */
  25. public const ON_WORKER_STOP = 'workerStop';
  26. /**
  27. * Swoole onWorkerExit event.
  28. */
  29. public const ON_WORKER_EXIT = 'workerExit';
  30. /**
  31. * Swoole onWorkerError event.
  32. */
  33. public const ON_WORKER_ERROR = 'workerError';
  34. /**
  35. * Swoole onPipeMessage event.
  36. */
  37. public const ON_PIPE_MESSAGE = 'pipeMessage';
  38. /**
  39. * Swoole onRequest event.
  40. */
  41. public const ON_REQUEST = 'request';
  42. /**
  43. * Swoole onReceive event.
  44. */
  45. public const ON_RECEIVE = 'receive';
  46. /**
  47. * Swoole onConnect event.
  48. */
  49. public const ON_CONNECT = 'connect';
  50. /**
  51. * Swoole onHandShake event.
  52. */
  53. public const ON_HAND_SHAKE = 'handshake';
  54. /**
  55. * Swoole onOpen event.
  56. */
  57. public const ON_OPEN = 'open';
  58. /**
  59. * Swoole onMessage event.
  60. */
  61. public const ON_MESSAGE = 'message';
  62. /**
  63. * Swoole onClose event.
  64. */
  65. public const ON_CLOSE = 'close';
  66. /**
  67. * Swoole onTask event.
  68. */
  69. public const ON_TASK = 'task';
  70. /**
  71. * Swoole onFinish event.
  72. */
  73. public const ON_FINISH = 'finish';
  74. /**
  75. * Swoole onShutdown event.
  76. */
  77. public const ON_SHUTDOWN = 'shutdown';
  78. /**
  79. * Swoole onPacket event.
  80. */
  81. public const ON_PACKET = 'packet';
  82. /**
  83. * Swoole onManagerStart event.
  84. */
  85. public const ON_MANAGER_START = 'managerStart';
  86. /**
  87. * Swoole onManagerStop event.
  88. */
  89. public const ON_MANAGER_STOP = 'managerStop';
  90. /**
  91. * Before server start, it's not a swoole event.
  92. */
  93. public const ON_BEFORE_START = 'beforeStart';
  94. public static function isSwooleEvent($event): bool
  95. {
  96. if ($event == self::ON_BEFORE_START) {
  97. return false;
  98. }
  99. return true;
  100. }
  101. }