protected function handleDispatch($data)
    {
        if (! is_null($hData = $this->handlers->getHandler($data->t))) {
            $handler = new $hData['class'](
                $this->http,
                $this->factory,
                $this->cache,
                $this
            );

            $deferred = new Deferred();
            $deferred->promise()->then(function ($d) use ($data, $hData) {
                if (is_array($d) && count($d) == 2) {
                    list($new, $old) = $d;
                } else {
                    $new = $d;
                    $old = null;
                }

                $this->emit($data->t, [$new, $this, $old]);

                foreach ($hData['alternatives'] as $alternative) {
                    $this->emit($alternative, [$d, $this]);
                }

                if ($data->t == Event::MESSAGE_CREATE && mentioned($this->client->user, $new)) {
                    $this->emit('mention', [$new, $this, $old]);
                }
            }, function ($e) use ($data) {
                $this->logger->warning('error while trying to handle dispatch packet', ['packet' => $data->t, 'error' => $e]);
            }, function ($d) use ($data) {
                $this->logger->warning('notified from event', ['data' => $d, 'packet' => $data->t]);
            });

            $parse = [
                Event::GUILD_CREATE,
            ];

            if (! $this->emittedReady && (array_search($data->t, $parse) === false)) {
                $this->unparsedPackets[] = function () use (&$handler, &$deferred, &$data) {
                    $handler->handle($deferred, $data->d);
                };
            } else {
                $handler->handle($deferred, $data->d);
            }
        }

        $handlers = [
            Event::VOICE_SERVER_UPDATE => 'handleVoiceServerUpdate',
            Event::RESUMED             => 'handleResume',
            Event::READY               => 'handleReady',
            Event::GUILD_MEMBERS_CHUNK => 'handleGuildMembersChunk',
            Event::VOICE_STATE_UPDATE  => 'handleVoiceStateUpdate',
        ];

        if (isset($handlers[$data->t])) {
            $this->{$handlers[$data->t]}($data);
        }
    }
protected function handleDispatch($data)
    {
        if (! is_null($hData = $this->handlers->getHandler($data->t))) {
            $handler = new $hData['class'](
                $this->http,
                $this->factory,
                $this->cache,
                $this
            );

            $deferred = new Deferred();
            $deferred->promise()->then(function ($d) use ($data, $hData) {
                if (is_array($d) && count($d) == 2) {
                    list($new, $old) = $d;
                } else {
                    $new = $d;
                    $old = null;
                }

                $this->emit($data->t, [$new, $this, $old]);

                foreach ($hData['alternatives'] as $alternative) {
                    $this->emit($alternative, [$d, $this]);
                }

                if ($data->t == Event::MESSAGE_CREATE && mentioned($this->client->user, $new)) {
                    $this->emit('mention', [$new, $this, $old]);
                }
            }, function ($e) use ($data) {
                $this->logger->warning('error while trying to handle dispatch packet', ['packet' => $data->t, 'error' => $e]);
            }, function ($d) use ($data) {
                $this->logger->warning('notified from event', ['data' => $d, 'packet' => $data->t]);
            });

            $parse = [
                Event::GUILD_CREATE,
            ];

            if (! $this->emittedReady && (array_search($data->t, $parse) === false)) {
                $this->unparsedPackets[] = function () use (&$handler, &$deferred, &$data) {
                    $handler->handle($deferred, $data->d);
                };
            } else {
                $handler->handle($deferred, $data->d);
            }
        }

        $handlers = [
            Event::VOICE_SERVER_UPDATE => 'handleVoiceServerUpdate',
            Event::RESUMED             => 'handleResume',
            Event::READY               => 'handleReady',
            Event::GUILD_MEMBERS_CHUNK => 'handleGuildMembersChunk',
            Event::VOICE_STATE_UPDATE  => 'handleVoiceStateUpdate',
        ];

        if (isset($handlers[$data->t])) {
            $this->{$handlers[$data->t]}($data);
        }
    }
protected function handleDispatch ( $ data ) { if ( ! is_null ( $ hData = $ this -> handlers -> getHandler ( $ data -> t ) ) ) { $ handler = new $ hData [ 'class' ] ( $ this -> http , $ this -> factory , $ this -> cache , $ this ) ; $ deferred = new Deferred ( ) ; $ deferred -> promise ( ) -> then ( function ( $ d ) use ( $ data , $ hData ) { if ( is_array ( $ d ) && count ( $ d ) == 2 ) { list ( $ new , $ old ) = $ d ; } else { $ new = $ d ; $ old = null ; } $ this -> emit ( $ data -> t , [ $ new , $ this , $ old ] ) ; foreach ( $ hData [ 'alternatives' ] as $ alternative ) { $ this -> emit ( $ alternative , [ $ d , $ this ] ) ; } if ( $ data -> t == Event :: MESSAGE_CREATE && mentioned ( $ this -> client -> user , $ new ) ) { $ this -> emit ( 'mention' , [ $ new , $ this , $ old ] ) ; } } , function ( $ e ) use ( $ data ) { $ this -> logger -> warning ( 'error while trying to handle dispatch packet' , [ 'packet' => $ data -> t , 'error' => $ e ] ) ; } , function ( $ d ) use ( $ data ) { $ this -> logger -> warning ( 'notified from event' , [ 'data' => $ d , 'packet' => $ data -> t ] ) ; } ) ; $ parse = [ Event :: GUILD_CREATE , ] ; if ( ! $ this -> emittedReady && ( array_search ( $ data -> t , $ parse ) === false ) ) { $ this -> unparsedPackets [ ] = function ( ) use ( & $ handler , & $ deferred , & $ data ) { $ handler -> handle ( $ deferred , $ data -> d ) ; } ; } else { $ handler -> handle ( $ deferred , $ data -> d ) ; } } $ handlers = [ Event :: VOICE_SERVER_UPDATE => 'handleVoiceServerUpdate' , Event :: RESUMED => 'handleResume' , Event :: READY => 'handleReady' , Event :: GUILD_MEMBERS_CHUNK => 'handleGuildMembersChunk' , Event :: VOICE_STATE_UPDATE => 'handleVoiceStateUpdate' , ] ; if ( isset ( $ handlers [ $ data -> t ] ) ) { $ this -> { $ handlers [ $ data -> t ] } ( $ data ) ; } }
Handles dispatch events received by the WebSocket.

@param object $data Packet data.
Handles dispatch events received by the WebSocket .