2020-08-31 01:27:08 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
2020-09-02 11:38:47 +08:00
|
|
|
namespace HttpServer\Events;
|
2020-08-31 01:27:08 +08:00
|
|
|
|
|
|
|
|
|
2020-09-02 17:02:13 +08:00
|
|
|
use Exception;
|
2020-09-04 01:05:33 +08:00
|
|
|
use HttpServer\Abstracts\Callback;
|
2020-09-02 17:02:13 +08:00
|
|
|
use Snowflake\Event;
|
|
|
|
|
use Snowflake\Exception\ComponentException;
|
|
|
|
|
use Snowflake\Snowflake;
|
|
|
|
|
use Swoole\Server;
|
2020-08-31 01:27:08 +08:00
|
|
|
|
2020-09-02 17:02:13 +08:00
|
|
|
/**
|
|
|
|
|
* Class OnPipeMessage
|
|
|
|
|
* @package HttpServer\Events
|
|
|
|
|
*/
|
2020-08-31 01:27:08 +08:00
|
|
|
class OnPipeMessage extends Callback
|
|
|
|
|
{
|
|
|
|
|
|
2020-09-02 17:02:13 +08:00
|
|
|
/**
|
|
|
|
|
* @param Server $server
|
|
|
|
|
* @param int $src_worker_id
|
|
|
|
|
* @param $message
|
|
|
|
|
* @throws ComponentException
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function onHandler(Server $server, int $src_worker_id, $message)
|
2020-08-31 01:27:08 +08:00
|
|
|
{
|
|
|
|
|
// TODO: Implement onHandler() method.
|
2020-09-03 11:39:20 +08:00
|
|
|
$events = Snowflake::app()->getEvent();
|
2020-09-02 17:02:13 +08:00
|
|
|
if (!$events->exists(Event::PIPE_MESSAGE)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$events->trigger(Event::PIPE_MESSAGE, [$server, $src_worker_id, $message]);
|
2020-08-31 01:27:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|