Handles dispatch events received by the WebSocket.

@param object $data Packet data.
490601
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);
        }
    }
231609
public function onInput($data)
    {
        //Process data here
        foreach ($this->params as $copy => $original) {
            $data[$copy] = $data[$original];
        }
        $this->next($data);
    }
1226032
function _dispatch(events, data) {
    var i,
        j,
        i_end,
        j_end,
        event,
        eventName,
        eArray = Array.isArray(events) ?
                   events :
                   events.split(/ /);

    data = data === undefined ? {} : data;

    for (i = 0, i_end = eArray.length; i !== i_end; i += 1) {
      eventName = eArray[i];

      if (_handlers[eventName]) {
        event = {
          type: eventName,
          data: data || {}
        };

        for (j = 0, j_end = _handlers[eventName].length; j !== j_end; j += 1)
          try {
            _handlers[eventName][j].handler(event);
          } catch (e) {}
      }
    }
  }
1117736
public function write($data)
    {
        if ($this->closed) {
            return;
        }

        $all = $this->tail . $data;
        $messages = $this->getParser()->consumeAll($all);
        $this->tail = $all;

        foreach ($messages as $message) {
            if (isset($message['message'])) {
                $this->emit('data', array($message['message']));
                $this->emit('irc.received', array($message));
            } elseif (isset($message['invalid'])) {
                $this->emit('invalid', array($message['invalid']));
            }
        }
    }
975866
public function failed(array $data)
	{
		$handler = $this->dispatcher->resolveHandler($command = unserialize($data['command']));

		if (method_exists($handler, 'failed'))
		{
			call_user_func([$handler, 'failed'], $command);
		}
	}
875700
public function handleWsError($e)
    {
        // Pawl pls
        if (strpos($e->getMessage(), 'Tried to write to closed stream') !== false) {
            return;
        }

        $this->logger->error('websocket error', ['e' => $e->getMessage()]);
        $this->emit('error', [$e, $this]);

        $this->handleWsClose(0, 'websocket error');
    }
1229485
public function handle(IPacketData $data)
    {
        if(isset($this->middlewares[$this->index]))
        {
            $middleware = $this->middlewares[$this->index];
            if($middleware instanceof IPacketHandler)
            {
                $requestHandler = $middleware;
            }
            else
            {
                $requestHandler = RequestContext::getServerBean($middleware);
            }
        }
        else
        {
            return null;
        }
        return $requestHandler->process($data, $this->next());
    }
896418
protected function onInput($data)
    {
        $func = $this->params;

        $data = $func($data);
        if ($data) {
            $this->next($data);
        }
    }
91430
public function handleData($data, $conn) {
        try {
            $this->app->onMessage($conn->decor, $data);
        } catch (\Exception $e) {
            $this->handleError($e, $conn);
        }
    }
385594
public function handle( $data )
    {
        $this->data = $data;

        if ( $message = $this->createMessage() )
        {
            $this->getMailer()->send( $message );
        }
    }
513462
protected function dispatchSentEvent($message, $data = [])
    {
        if ($this->events) {
            $this->events->dispatch(
                new Events\MessageSent($message->getSwiftMessage(), $data)
            );
        }
    }
1164318
final public function dispatch(Event $event): void
    {
        if (!$event instanceof ReceivedEvent && $this->discriminator->shouldEnqueue($event)) {
            $this->queue->send($event);
        }

        if ($event instanceof ReceivedEvent) {
            $event = $event->getOriginalEvent();
        }

        $this->wrappedEventBus->dispatch($event);
    }
732440
protected function processClientSocket($socket): void
    {
        $connection = $this->getConnectionForClientSocket($socket);

        if (!$connection) {
            $this->logger->warning('No connection for client socket');
            return;
        }

        try {
            $this->server->notify(Server::EVENT_CLIENT_DATA, [$socket, $connection]);

            $connection->process();
        } catch (CloseException $e) {
            $this->logger->notice('Client connection closed: {exception}', [
                'exception' => $e,
            ]);
            $connection->close(Protocol::CLOSE_UNEXPECTED, $e->getMessage());
        } catch (WrenchException $e) {
            $this->logger->warning('Error on client socket: {exception}', [
                'exception' => $e,
            ]);
            $connection->close(Protocol::CLOSE_UNEXPECTED);
        } catch (InvalidArgumentException $e) {
            $this->logger->warning('Wrong input arguments: {exception}', [
                'exception' => $e,
            ]);
            $connection->close(Protocol::CLOSE_UNEXPECTED);
        }
    }
866449
public void handleData(String data) {
		try {
			sendEvent(new ClickEvent(this.user, getPayload()));
			if (clickHandler != null)
				clickHandler.clicked();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
1130223
public void dispatch_event(final EventData eventData) {
        final TangoInterfaceChange interfaceChange = this;
        if (EventUtil.graphicAvailable()) {
            //   Causes doRun.run() to be executed asynchronously
            //      on the AWT event dispatching thread.
            Runnable do_work_later = new Runnable() {
                public void run() {
                    fireTangoInterfaceChangeEvent(interfaceChange, eventData);
                }
            };
            SwingUtilities.invokeLater(do_work_later);
        }
        else {
            fireTangoInterfaceChangeEvent(interfaceChange, eventData);
        }
    }
878755
public function handlePayload(Payload $payload): void
    {
        $app = $this->getClientApplication();

        $this->logger->debug('Handling payload: ' . $payload->getPayload());

        switch ($type = $payload->getType()) {
            case Protocol::TYPE_TEXT:
                if (method_exists($app, 'onData')) {
                    $app->onData((string)$payload, $this);
                }
                return;

            case Protocol::TYPE_BINARY:
                if (method_exists($app, 'onBinaryData')) {
                    $app->onBinaryData((string)$payload, $this);
                } else {
                    $this->close(1003);
                }
                break;

            case Protocol::TYPE_PING:
                $this->logger->info('Ping received', 'notice');
                $this->send($payload->getPayload(), Protocol::TYPE_PONG);
                $this->logger->info('Pong!', 'debug');
                break;

            /**
             * A Pong frame MAY be sent unsolicited.  This serves as a
             * unidirectional heartbeat.  A response to an unsolicited Pong
             * frame is not expected.
             */
            case Protocol::TYPE_PONG:
                $this->logger->info('Received unsolicited pong');
                break;

            case Protocol::TYPE_CLOSE:
                $this->logger->notice('Close frame received');
                $this->close();
                $this->logger->info('Disconnected');
                break;

            default:
                throw new ConnectionException('Unhandled payload type');
        }
    }
464614
public function handleDisconnect($socket)
    {
        try
        {
            $this->component->handleDisconnect($socket->conn);
        }
        catch (Error $ex)
        {
            $this->handleError($socket, $ex);
        }
        catch (Exception $ex)
        {
            $this->handleError($socket, $ex);
        }

        unset($socket->conn);
    }