This commit is contained in:
2020-09-02 17:02:13 +08:00
parent 7e7996dab0
commit f64942424b
2 changed files with 24 additions and 1 deletions
+22 -1
View File
@@ -4,14 +4,35 @@
namespace HttpServer\Events;
use Exception;
use HttpServer\Events\Abstracts\Callback;
use Snowflake\Event;
use Snowflake\Exception\ComponentException;
use Snowflake\Snowflake;
use Swoole\Server;
/**
* Class OnPipeMessage
* @package HttpServer\Events
*/
class OnPipeMessage extends Callback
{
public function onHandler()
/**
* @param Server $server
* @param int $src_worker_id
* @param $message
* @throws ComponentException
* @throws Exception
*/
public function onHandler(Server $server, int $src_worker_id, $message)
{
// TODO: Implement onHandler() method.
$events = Snowflake::get()->getEvent();
if (!$events->exists(Event::PIPE_MESSAGE)) {
return;
}
$events->trigger(Event::PIPE_MESSAGE, [$server, $src_worker_id, $message]);
}
}
+2
View File
@@ -22,6 +22,8 @@ class Event extends BaseObject
const EVENT_STOP = 'WORKER:STOP';
const EVENT_EXIT = 'WORKER:EXIT';
const PIPE_MESSAGE = 'SERVER:PIPE:MESSAGE';
const EVENT_AFTER_REQUEST = 'SERVER:REQUEST:AFTER:START';
const EVENT_BEFORE_REQUEST = 'SERVER:REQUEST:BEFORE:START';
const RECEIVE_CONNECTION = 'SERVER:RECEIVE:CONNECTION';