Handles `READY` packets.

@param object $data Packet data.
356963
protected function handleReady($data)
    {
        $this->logger->debug('ready packet received');

        // If this is a reconnect we don't want to
        // reparse the READY packet as it would remove
        // all the data cached.
        if ($this->reconnecting) {
            $this->reconnecting = false;
            $this->logger->debug('websocket reconnected to discord through identify');

            return;
        }

        $content = $data->d;
        $this->emit('trace', $data->d->_trace);
        $this->logger->debug('discord trace received', ['trace' => $content->_trace]);

        // Setup the user account
        $this->client    = $this->factory->create(Client::class, $content->user, true);
        $this->sessionId = $content->session_id;

        $this->logger->debug('client created and session id stored', ['session_id' => $content->session_id, 'user' => $this->client->user->getPublicAttributes()]);

        // Private Channels
        $private_channels = new PrivateChannelRepository(
            $this->http,
            $this->cache,
            $this->factory
        );

        if ($this->options['pmChannels']) {
            foreach ($content->private_channels as $channel) {
                $channelPart = $this->factory->create(Channel::class, $channel, true);
                $this->cache->set("pm_channels.{$channelPart->recipient->id}", $channelPart);
                $private_channels->push($channelPart);
            }

            $this->logger->info('stored private channels', ['count' => $private_channels->count()]);
        } else {
            $this->logger->info('did not parse private channels');
        }

        $this->private_channels = $private_channels;

        // Guilds
        $this->guilds = new GuildRepository(
            $this->http,
            $this->cache,
            $this->factory
        );
        $event = new GuildCreate(
            $this->http,
            $this->factory,
            $this->cache,
            $this
        );

        $unavailable = [];

        foreach ($content->guilds as $guild) {
            $deferred = new Deferred();

            $deferred->promise()->then(null, function ($d) use (&$unavailable) {
                list($status, $data) = $d;

                if ($status == 'unavailable') {
                    $unavailable[$data] = $data;
                }
            });

            $event->handle($deferred, $guild);
        }

        $this->logger->info('stored guilds', ['count' => $this->guilds->count()]);

        if (count($unavailable) < 1) {
            return $this->ready();
        }

        // Emit ready after 60 seconds
        $this->loop->addTimer(60, function () {
            $this->ready();
        });

        $function = function ($guild) use (&$function, &$unavailable) {
            if (array_key_exists($guild->id, $unavailable)) {
                unset($unavailable[$guild->id]);
            }

            // todo setup timer to continue after x amount of time
            if (count($unavailable) < 1) {
                $this->logger->info('all guilds are now available', ['count' => $this->guilds->count()]);
                $this->removeListener(Event::GUILD_CREATE, $function);

                $this->setupChunking();
            }
        };

        $this->on(Event::GUILD_CREATE, $function);
    }
609848
public function setData($data)
    {
        if (!is_string($data)) {
            $data = json_encode($data);
        }

        $this->data = $data;
    }
716145
private function send(string $data):void
    {

        socket_write($this->socket, $data, strlen($data)) or $this->error();

    }
846898
public function refreshCacheUsing($data)
    {
        Cache::forever($this->cacheKey, $data);
        Cache::forever($this->cacheTimestampKey, time());
    }
912520
public function set_data( $data ) {

		foreach ( $this->child as $child ) {
			if ( method_exists( $child, 'set_data' ) ) {
				$child->set_data( $data );
			}
		}
		$this->data = $data;

	}
1131305
public function load($data)
    {
        if (is_object($data)) {
            $data = get_object_vars($data);
        }
        foreach ($data as $index => $value) {
            if ($index == 'tags' && !is_array($value)) {
                if (isset($value->tag)) {
                    $value = (!is_array($value->tag)) ? array($value->tag) : $value->tag;
                }
            }
            $this->$index = $value;
        }
    }
317498
protected function prepareData(&$data)
    {
        // Remove MatchOn Filter:
        
        $name = $this->getMatchOnName();
        
        if (isset($data[$name])) {
            unset($data[$name]);
        }
    }
667337
public function data($data)
    {
        if($this->state == Connection::READ_HEADERS) {
            if(!$this->start_time) $this->start_time = microtime(true);
            $this->header_buffer .= $data;

            $end = strpos($this->header_buffer, "\r\n\r\n", 4);
            if($end === false) return;

            // parse HTTP request
            $this->parse_request(substr($this->header_buffer, 0, $end));

            // TODO: check for Transfer-Encoding: chunked

            $this->content_length = (int)$this->get_header('Content-Length');

            $body_start = $end + 4;
            $data = substr($this->header_buffer, $body_start);

            $this->state = Connection::READ_CONTENT;
        }

        if($this->state == Connection::READ_CONTENT) {
            if($this->is_chunked) {
                // TODO: Handle chunked data
            } else {
                fwrite($this->body, $data);
                $this->bytes_read += strlen($data);

                if($this->content_length - $this->bytes_read <= 0) $this->state = Connection::READ_COMPLETE;
            }
        }

        if($this->state == Connection::READ_COMPLETE) fseek($this->body, 0);
    }
1129355
protected function handleReconnect($data)
    {
        $this->logger->warning('received opcode 7 for reconnect');

        $this->ws->close(
            Op::CLOSE_NORMAL,
            'gateway redirecting - opcode 7'
        );
    }
873825
protected function prepareRawPayload($data)
    {
        $this->clearRequestParams();
        $this->addHeader('Content-Length', strlen($data));
        $this->addOption(CURLOPT_POSTFIELDS, $data);
    }
303961
def handle(self, data):
        
        self.dataResponseCode.append(self._doPut(self.sendURL + '/data', data=data))
632373
public function sendData($data)
    {
        if ($this->isConnected()) {
            if (socket_write($this->socket, $data, strlen($data)) === false) {
                $this->eventManager()->fire('onClose',
                   [
                        $this->phoneNumber,
                        'Connection closed!',
                    ]
              );
            }
        }
    }
355235
function _data_handler($parser, $data)
    {
        if (!isset($this->current) || is_object($this->current)) {
            return;
        }
        $this->current.= trim($data);
    }
238622
protected function prepare()
    {
        if (!is_array($this->data) || count($this->data) == 0) {
            $this->setData($this->read());
        }
    }
626483
public function addData($data) : void
    {
        Assert::isInstanceOfAny($data, [Chunk::class, X509Certificate::class]);
        $this->data[] = $data;
    }
101005
protected function onInput($data)
    {
        //Process data here
        foreach ($this->params as $column) {
            unset($data[$column]);
        }
        $this->next($data);
    }
227485
public function jsonResponse($data)
    {
        $this->_headers[] = 'Content-Type: application/json';

        if (!headers_sent()) {
            foreach ($this->_headers as $header) {
                header($header, true);
            }
        }
        echo json_encode($data);
    }