src/Server.php
function event(string $event, callable $callback) {
        if (self::$_status > self::_STATUS_INITIAL) {
            Console::warning('Cannot set event callback once the service is started.');
            return;
        }
        if (!is_callable($callback)) {
            Console::warning('Failed to set event callback. Not callable.');
            return;
        }
        switch ($event) {
            case 'WorkerStart':
                $this->_on_start = $callback;
                break;
            case 'WorkerStop':
                $this->_on_stop = $callback;
                break;
            case 'Message':
                $this->_on_message = $callback;
                break;
            default:
                $this->_worker->{'on'.$event} = $callback;
        }
    }
function event(string $event, callable $callback) {
        if (self::$_status > self::_STATUS_INITIAL) {
            Console::warning('Cannot set event callback once the service is started.');
            return;
        }
        if (!is_callable($callback)) {
            Console::warning('Failed to set event callback. Not callable.');
            return;
        }
        switch ($event) {
            case 'WorkerStart':
                $this->_on_start = $callback;
                break;
            case 'WorkerStop':
                $this->_on_stop = $callback;
                break;
            case 'Message':
                $this->_on_message = $callback;
                break;
            default:
                $this->_worker->{'on'.$event} = $callback;
        }
    }
绑定事件回调

@param string $event
@param callable $callback