绑定服务器事件
@return void
438739
protected function __bindEvents()
    {
        $server = $this->swoolePort ?? $this->swooleServer;

        $server->on('handShake', function(\swoole_http_request $swooleRequest, \swoole_http_response $swooleResponse){
            try{
                $request = new Request($this, $swooleRequest);
                $response = new Response($this, $swooleResponse);
                $this->trigger('handShake', [
                    'request'   => &$request,
                    'response'  => &$response,
                ], $this, HandShakeEventParam::class);
            }
            catch(\Throwable $ex)
            {
                App::getBean('ErrorLog')->onException($ex);
            }
        });

        $server->on('message', function (\swoole_websocket_server $server, \swoole_websocket_frame $frame) {
            try{
                $this->trigger('message', [
                    'server'    => $this,
                    'frame'     => $frame,
                ], $this, MessageEventParam::class);
            }
            catch(\Throwable $ex)
            {
                App::getBean('ErrorLog')->onException($ex);
            }
        });

        $server->on('close', function(\swoole_http_server $server, $fd, $reactorID){
            try{
                $this->trigger('close', [
                    'server'    => $this,
                    'fd'        => $fd,
                    'reactorID' => $reactorID,
                ], $this, CloseEventParam::class);
            }
            catch(\Throwable $ex)
            {
                App::getBean('ErrorLog')->onException($ex);
            }
        });
    }
560271
public static function begin(): void
  {
    $ret = self::$mysqli->autocommit(false);
    if (!$ret) self::mySqlError('mysqli::autocommit');
  }
172352
private function preBindDoctrineEvent() : void
    {
        if(EventScheduler::instance()->has(Event::DATA_CHANGED)){
            $this->getEventManager()->addEventListener([Events::postPersist, Events::postUpdate, Events::postRemove], new Class{
                public function postPersist(LifecycleEventArgs $args) : void
                {
                    EventScheduler::instance()->trigger(Event::DATA_CHANGED, ['created', $args->getEntityManager(), $args->getEntity()]);
                }

                public function postUpdate(LifecycleEventArgs $args) : void
                {
                    EventScheduler::instance()->trigger(Event::DATA_CHANGED, ['updated', $args->getEntityManager(), $args->getEntity()]);
                }

                public function postRemove(LifecycleEventArgs $args) : void
                {
                    EventScheduler::instance()->trigger(Event::DATA_CHANGED, ['deleted', $args->getEntityManager(), $args->getEntity()]);
                }
            });
        }
    }
1214402
protected function bind()
    {
        if (!isset($this->di)) {
            return false;
        }
        foreach ($this->di as $contract => $object) {
            $this->app->bind($contract, $object);
        }
    }
201120
public function commit()
    {
        if ($this->transactions == 1) $this->pdo->commit();

        --$this->transactions;

        $this->fireConnectionEvent('committed');
    }
184603
public function handle()
    {

        if (! $this->preflighted()) return;

        $event_ids = CharacterCalendarEvent::where('character_id', $this->getCharacterId())
            ->whereNotIn('event_id', function ($query) {

                $query->select('event_id')
                    ->from('character_calendar_event_details');

            })->pluck('event_id');

        $event_ids->each(function ($event_id) {

            try {
                $detail = $this->retrieve([
                    'character_id' => $this->getCharacterId(),
                    'event_id' => $event_id,
                ]);

                if ($detail->isCachedLoad()) return;

                CharacterCalendarEventDetail::firstOrCreate([
                    'event_id' => $event_id,
                ], [
                    'owner_id' => $detail->owner_id,
                    'owner_name' => $detail->owner_name,
                    'duration' => $detail->duration,
                    'text' => $detail->text,
                    'owner_type' => $detail->owner_type,
                ]);
            } catch (RequestFailedException $e) {
                if (strtolower($e->getError()) == 'event not found!') {
                    CharacterCalendarEvent::where('character_id', $this->getCharacterId())
                                          ->where('event_id', $event_id)
                                          ->delete();

                    return;
                }

                throw $e;
            }
        });
    }
1196585
static private function bindEventListenersEvents()
    {
    	if (self::$_eventListeners && !self::$_elInstances) {
    		foreach (self::$_eventListeners as $class => $listeners) {
    			if ($listeners) foreach ($listeners as $listener) {
    				
    				$listener = self::getListener($listener);
    				
    				$events = $listener->events();
    				
    				if ($events) foreach ($events as $name => $handler) {
    					Event::on($class, $name, is_string($handler) ? [$listener, $handler] : $handler);
    				}
    			}
    		}
    	}
    }
1218013
public function handle() : void
    {
        if ($module = $this->option('module')) {
            $this->input->setOption('path', 'modules/' . $module . '/database/migrations');
        }

        parent::handle();
    }
761006
public function reload()
    {
        if ($this['object'] === 'event') {
            parent::g_reload(self::getUrl($this['id']));
        } else {
            parent::g_reload(self::getUrl());
        }
    }
997412
public function handle(): void
    {
        // Log
        $this->getService('logging')->debug(sprintf('%s / Initialization', __METHOD__));

        // Event
        $this->getService('events')->trigger('_berlioz.core.app.handle.before', $this);

        // Get router
        /** @var \Berlioz\Core\Services\Routing\RouterInterface $router */
        $router = $this->getService('routing');

        // Get route set from cache
        if ($this->getConfig()->hasCacheEnabled() && $this->hasService('caching') && $this->getService('caching')->has(self::CACHE_KEY_ROUTING)) {
            /** @var \Berlioz\Core\Services\Routing\RouteSetInterface $routeSet */
            $routeSet = $this->getService('caching')->get(self::CACHE_KEY_ROUTING);

            // Define route set from cache
            $router->setRouteSet($routeSet);

            // Log
            $this->getService('logging')->debug(sprintf('%s / Router gotten from cache', __METHOD__));
        } else {
            // Register routes ans exceptions
            $this->register();

            // Log
            $this->getService('logging')->debug(sprintf('%s / Routes and exceptions declared', __METHOD__));

            if ($this->getConfig()->hasCacheEnabled() && $this->hasService('caching')) {
                $this->getService('caching')->set(self::CACHE_KEY_ROUTING, $router->getRouteSet());

                // Log
                $this->getService('logging')->debug(sprintf('%s / Router saved in cache', __METHOD__));
            }
        }

        // Handle router
        $response = $router->handle();

        // Debug
        $this->getService('logging')->debug(sprintf('%s / Done', __METHOD__));

        if ($response instanceof ResponseInterface) {
            // Headers
            if (!headers_sent()) {
                // Remove headers and add main header
                header_remove();
                header('HTTP/' . $response->getProtocolVersion() . ' ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase(), false);

                // Headers
                foreach ($response->getHeaders() as $name => $values) {
                    $replace = true;
                    foreach ($values as $value) {
                        header(sprintf('%s: %s', $name, $value), $replace);
                        $replace = false;
                    }
                }
            }

            // Content
            print $response->getBody();
        } else {
            print $response;
        }

        // Log
        $this->getService('logging')->debug(sprintf('%s / Response printed', __METHOD__));

        // Event
        $this->getService('events')->trigger('_berlioz.core.app.handle.after', $this);
    }
810820
public function fireEvent(string $event): void
    {
        $this->log->debug('Event {event} has been fired.', ['event' => $event]);
        foreach ($this->event_handlers as $handler) {
            /** @var EventHandler $handler */
            if ($event === $handler->getEvent()) {
                $handler->execute();
            }
        }
    }
327380
public function register()
    {
        parent::register();

        $this->app->booted(function (Application $app) {
            $this->registerEventListeners($app->make('events'));
        });
    }
199931
public function start()
    {
        foreach ($this->callbacks as $event => $callback) {
            $this->client->on($event, $callback);
        }
        $this->connect();
    }
745037
public function run()
    {
        // todo: think of a better way of doing this.
        $script = "jQuery('{$this->selector}').attr('data-spy', 'scroll');";
        if (isset($this->target)) {
            $script .= "jQuery('{$this->selector}').attr('data-target', '{$this->target}');";
        }
        if (isset($this->offset)) {
            $script .= "jQuery('{$this->selector}').attr('data-offset', '{$this->offset}');";
        }
        Yii::app()->clientScript->registerScript($this->getId(), $script, CClientScript::POS_BEGIN);
        $this->registerEvents($this->selector, $this->events);
    }
207750
public function on_start()
    {
        $this->registerServiceProvider();
        $this->registerParsers();
        $this->app->make('director')->addSubscriber($this->app->make(EventSubscriber::class));
        if ($this->app->isRunThroughCommandLineInterface()) {
            $this->registerCLICommands();
        } else {
            $this->registerAssets();
            $this->registerRoutes();
        }
    }
229304
protected function __bindEvents()
    {
        $server = $this->swoolePort ?? $this->swooleServer;

        $server->on('packet', function(\swoole_server $server, $data, $clientInfo){
            try{
                $this->trigger('packet', [
                    'server'        => $this,
                    'data'          => $data,
                    'clientInfo'    => $clientInfo,
                ], $this, PacketEventParam::class);
            }
            catch(\Throwable $ex)
            {
                App::getBean('ErrorLog')->onException($ex);
            }
        });
        
    }
639207
public function listen()
    {
        $this->connection->enableQueryLog();

        $this->connection->listen(function (QueryExecuted $event) {
            $this->logQuery($event->connectionName, $event->sql, $event->bindings, $event->time);
        });
    }