Enables the delay detection when preconditions are fulfilled.

@param Frame $frame
@return void
499649
private function enable(Frame $frame)
    {
        $this->onHeartbeatFrame($frame, $this->getHeartbeats($frame));
        if ($this->intervalServer && $this->intervalClient) {
            $intervalAgreement = $this->calculateInterval(max($this->intervalClient, $this->intervalServer));
            $this->intervalUsed = $intervalAgreement / 1000; // milli to micro
            if ($intervalAgreement) {
                $this->enabled = true;
                $this->rememberActivity();
            }
        }
    }
91108
async def handle_frame(self, frame):
        """"""
        if isinstance(frame, FrameCommandSendConfirmation) and frame.session_id == self.session_id:
            if frame.status == CommandSendConfirmationStatus.ACCEPTED:
                self.success = True
            return not self.wait_for_completion
        if isinstance(frame, FrameCommandRemainingTimeNotification) and frame.session_id == self.session_id:
            # Ignoring FrameCommandRemainingTimeNotification
            return False
        if isinstance(frame, FrameCommandRunStatusNotification) and frame.session_id == self.session_id:
            # At the moment I don't reall understand what the FrameCommandRunStatusNotification is good for.
            # Ignoring these packets for now
            return False
        if isinstance(frame, FrameSessionFinishedNotification) and frame.session_id == self.session_id:
            return True
        return False
959988
protected function wait_frame($timeout = 0)
    {
        if (is_null($this->input))
        {
            $this->setIsConnected(false);
            throw new AMQPConnectionClosedException('Broken pipe or closed connection');
        }

        $currentTimeout = $this->input->getTimeout();
        $this->input->setTimeout($timeout);

        try {
            // frame_type + channel_id + size
            $this->wait_frame_reader->reuse(
                $this->input->read(AMQPReader::OCTET + AMQPReader::SHORT + AMQPReader::LONG)
            );

            $frame_type = $this->wait_frame_reader->read_octet();
            $class = self::$PROTOCOL_CONSTANTS_CLASS;
            if (!array_key_exists($frame_type, $class::$FRAME_TYPES)) {
                throw new AMQPInvalidFrameException('Invalid frame type ' . $frame_type);
            }
            $channel = $this->wait_frame_reader->read_short();
            $size = $this->wait_frame_reader->read_long();

            // payload + ch
            $this->wait_frame_reader->reuse($this->input->read(AMQPReader::OCTET + (int) $size));

            $payload = $this->wait_frame_reader->read($size);
            $ch = $this->wait_frame_reader->read_octet();

        } catch (AMQPTimeoutException $e) {
            $this->input->setTimeout($currentTimeout);
            throw $e;
        } catch (AMQPNoDataException $e) {
            if ($this->input) {
                $this->input->setTimeout($currentTimeout);
            }
            throw $e;
        } catch (AMQPConnectionClosedException $exception) {
            $this->do_close();
            throw $exception;
        }

        $this->input->setTimeout($currentTimeout);

        if ($ch != 0xCE) {
            throw new AMQPInvalidFrameException(sprintf(
                'Framing error, unexpected byte: %x',
                $ch
            ));
        }

        return array($frame_type, $channel, $payload);
    }
977115
public function onConstruct($app)
    {
        //if not null
        if (!is_null($app)) {
            $key = $this->settingsKey;
            $this->$key = $app;
        }
    }
1333991
public function toggleFramed( $framed = null ) {
		$this->framed = $framed !== null ? (bool)$framed : !$this->framed;
		$this->toggleClasses( [ 'oo-ui-buttonElement-framed' ], $this->framed );
		$this->toggleClasses( [ 'oo-ui-buttonElement-frameless' ], !$this->framed );
		return $this;
	}
653986
public function getSubscription(Frame $frame)
    {
        foreach ($this->subscriptions as $subscription) {
            if ($subscription->belongsTo($frame)) {
                return $subscription;
            }
        }
        return false;
    }
396062
public function sendFrame($frame)
    {
        $this->outputFrame("<script>\np(" . htmlspecialchars(json_encode($frame, JSON_UNESCAPED_SLASHES),
                ENT_NOQUOTES | ENT_HTML401) . ");\n</script>\r\n");
        parent::sendFrame($frame);
    }
1331231
public function frameCheck(FrameInterface $frame) {
        if (false !== $frame->getRsv1() ||
            false !== $frame->getRsv2() ||
            false !== $frame->getRsv3()
        ) {
            return $this->newCloseFrame(Frame::CLOSE_PROTOCOL, 'Ratchet detected an invalid reserve code');
        }

        if ($this->checkForMask && !$frame->isMasked()) {
            return $this->newCloseFrame(Frame::CLOSE_PROTOCOL, 'Ratchet detected an incorrect frame mask');
        }

        $opcode = $frame->getOpcode();

        if ($opcode > 2) {
            if ($frame->getPayloadLength() > 125 || !$frame->isFinal()) {
                return $this->newCloseFrame(Frame::CLOSE_PROTOCOL, 'Ratchet detected a mismatch between final bit and indicated payload length');
            }

            switch ($opcode) {
                case Frame::OP_CLOSE:
                    $closeCode = 0;

                    $bin = $frame->getPayload();

                    if (empty($bin)) {
                        return $this->newCloseFrame(Frame::CLOSE_NORMAL);
                    }

                    if (strlen($bin) === 1) {
                        return $this->newCloseFrame(Frame::CLOSE_PROTOCOL, 'Ratchet detected an invalid close code');
                    }

                    if (strlen($bin) >= 2) {
                        list($closeCode) = array_merge(unpack('n*', substr($bin, 0, 2)));
                    }

                    $checker = $this->closeFrameChecker;
                    if (!$checker($closeCode)) {
                        return $this->newCloseFrame(Frame::CLOSE_PROTOCOL, 'Ratchet detected an invalid close code');
                    }

                    if (!$this->checkUtf8(substr($bin, 2))) {
                        return $this->newCloseFrame(Frame::CLOSE_BAD_PAYLOAD, 'Ratchet detected an invalid UTF-8 payload in the close reason');
                    }

                    return $frame;
                    break;
                case Frame::OP_PING:
                case Frame::OP_PONG:
                    break;
                default:
                    return $this->newCloseFrame(Frame::CLOSE_PROTOCOL, 'Ratchet detected an invalid OP code');
                    break;
            }

            return $frame;
        }

        if (Frame::OP_CONTINUE === $frame->getOpcode() && 0 === count($this->messageBuffer)) {
            return $this->newCloseFrame(Frame::CLOSE_PROTOCOL, 'Ratchet detected the first frame of a message was a continue');
        }

        if (count($this->messageBuffer) > 0 && Frame::OP_CONTINUE !== $frame->getOpcode()) {
            return $this->newCloseFrame(Frame::CLOSE_PROTOCOL, 'Ratchet detected invalid OP code when expecting continue frame');
        }

        return $frame;
    }
1357140
public function dispatch(IncomingFrame $incomingFrame)
    {
        switch (true) {
            case $incomingFrame instanceof Basic\BasicDeliverFrame:
            case $incomingFrame instanceof Basic\BasicGetOkFrame:
                $message = new Message();
                $message->setRoutingKey($incomingFrame->routingKey)
                    ->setExchange($incomingFrame->exchange)
                    ->setTag($incomingFrame->deliveryTag)
                    ->setChannel($this);
                $object = new \stdClass();
                if ($incomingFrame instanceof Basic\BasicDeliverFrame) {
                    $object->consumerTag = $incomingFrame->consumerTag;
                }
                $object->message = $message;
                $this->stack->attach($object);
                $this->stack->rewind();
                break;
            case $incomingFrame instanceof Basic\BasicHeaderFrame:
                $object = $this->stack->current();
                /** @var Message $message */
                $message = $object->message;
                $message->setContentLength($incomingFrame->contentLength)
                    ->setContentType($incomingFrame->contentType)
                    ->setContentEncoding($incomingFrame->contentEncoding)
                    ->setHeaders($incomingFrame->headers)
                    ->setMessageId($incomingFrame->messageId)
                    ->setDeliveryMode($incomingFrame->deliveryMode)
                    ->setCorrelationId($incomingFrame->correlationId)
                    ->setReplyTo($incomingFrame->replyTo)
                    ->setExpiration($incomingFrame->expiration)
                    ->setTimestamp($incomingFrame->timestamp)
                    ->setType($incomingFrame->type)
                    ->setUserId($incomingFrame->userId)
                    ->setAppId($incomingFrame->appId)
                    ->setClusterId($incomingFrame->clusterId);
                $object->totalPayloadSize = $incomingFrame->contentLength;
                break;
            case $incomingFrame instanceof BodyFrame:
                $object = $this->stack->current();
                /**
                 * Use only php strlen because wee need string length in bytes
                 */
                $currentContentLength = strlen($incomingFrame->content);

                /** @var Message $message */
                $message = $object->message;
                $message->setContent($message->getContent() . $incomingFrame->content);

                $object->totalPayloadSize -= $currentContentLength;

                if ($object->totalPayloadSize === 0) {
                    if (isset($object->consumerTag)) {
                        $this->trigger(self::EVENT_DISPATCH_CONSUMER_MESSAGE, $object->consumerTag, $message);
                    } else {
                        $this->triggerOneAndUnbind(self::EVENT_DISPATCH_MESSAGE, $message);
                    }
                    $this->stack->detach($object);
                }
                break;
            case $incomingFrame instanceof Basic\BasicGetEmptyFrame:
                $this->triggerOneAndUnbind(self::EVENT_DISPATCH_MESSAGE, false);
                break;
            case $incomingFrame instanceof Basic\BasicCancelOkFrame:
                unset($this->consumers[$incomingFrame->consumerTag]);
                break;

            case $incomingFrame instanceof ProtocolChannel\ChannelOpenOkFrame:
                $this->isConnected = true;
                $this->id = $incomingFrame->frameChannelId;
                //write QoS
                $outputFrame = Basic\BasicQosFrame::create(
                    self::QOS_PREFECTH_SIZE,
                    self::QOS_PREFETCH_COUNT
                );
                $outputFrame->frameChannelId = $incomingFrame->frameChannelId;
                $this->connection->command($outputFrame);
                break;
            case $incomingFrame instanceof ProtocolChannel\ChannelCloseFrame:
                $this->trigger(self::EVENT_ON_CHANNEL_CLOSE_CALLBACK);
                Daemon::log(sprintf('[AMQP] Channel closed by broker. Reason: %s[%d]', $incomingFrame->replyText, $incomingFrame->replyCode));
                $this->isConnected = false;
                break;
            case $incomingFrame instanceof Basic\BasicQosOkFrame:
                $this->trigger(self::EVENT_ON_CHANNEL_OPEN_CALLBACK, $this);
                break;
            case $incomingFrame instanceof Basic\BasicConsumeOkFrame:
                $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_CONSUMEOK_CALLBACK, $incomingFrame);
                break;
            case $incomingFrame instanceof ProtocolChannel\ChannelCloseOkFrame:
                $this->isConnected = false;
                break;
            case $incomingFrame instanceof Queue\QueueDeclareOkFrame:
                $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DECLARE_QUEUE_CALLBACK);
                break;
            case $incomingFrame instanceof Queue\QueueDeleteOkFrame:
                $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DELETE_QUEUE_CALLBACK);
                break;
            case $incomingFrame instanceof Queue\QueuePurgeOkFrame:
                $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_PURGE_QUEUE_CALLBACK);
                break;
            case $incomingFrame instanceof Queue\QueueBindOkFrame:
                $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_BIND_QUEUE_CALLBACK);
                break;
            case $incomingFrame instanceof Queue\QueueUnbindOkFrame:
                $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_UNBIND_QUEUE_CALLBACK);
                break;
            case $incomingFrame instanceof Exchange\ExchangeDeclareOkFrame:
                $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DECLARE_EXCHANGE_CALLBACK);
                break;
            case $incomingFrame instanceof Exchange\ExchangeDeleteOkFrame:
                $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DELETE_EXCHANGE_CALLBACK);
                break;
            case $incomingFrame instanceof Exchange\ExchangeBindOkFrame:
                $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_BIND_EXCHANGE_CALLBACK);
                break;
            case $incomingFrame instanceof Exchange\ExchangeUnbindOkFrame:
                $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_UNBIND_EXCHANGE_CALLBACK);
                break;
        }
    }
495240
protected function _validateFrame($frame) {
    if(!is_array($frame) || count($frame) !== 1 || !is_object($frame[0])) {
      throw new JsonLdException(
        'Invalid JSON-LD syntax; a JSON-LD frame must be a single object.',
        'jsonld.SyntaxError', null, array('frame' => $frame));
    }
  }
1205000
public function onMessage($server, $frame) {
        $data = json_decode($frame->data, true);
        $method = $data[ 'method' ];
        unset($data[ 'method' ]);
        $user_id = $this->fidToUserId($frame->fd);
        /* @var $service WebSocketService */
        $service = Ioc::get($this->config[ 'service' ]);
        $service->$method($user_id, $data);
        CoContext::getContext()->release();
    }
1280037
protected function processControlFrame(WebSocketFrame $frame)
    {
        switch ($frame->getType()) {
            case WebSocketOpcode::CloseFrame :
                $this->logger->notice("Got CLOSE frame");

                $frame = WebSocketFrame::create(WebSocketOpcode::CloseFrame);
                $this->sendFrame($frame);

                $this->_socket->close();
                break;
            case WebSocketOpcode::PingFrame :
                $frame = WebSocketFrame::create(WebSocketOpcode::PongFrame, $frame->getData());
                $this->sendFrame($frame);
                break;
        }
    }
917586
private void processSETTINGSFrame() throws FlowControlException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "processSETTINGSFrame entry:\n" + currentFrame.toString());
        }
        // check if this is the first non-ACK settings frame received; if so, update connection init state
        if (!connection_preface_settings_rcvd && !((FrameSettings) currentFrame).flagAckSet()) {
            connection_preface_settings_rcvd = true;
        }
        if (((FrameSettings) currentFrame).flagAckSet()) {
            // if this is the first ACK frame, update connection init state
            if (!connection_preface_settings_ack_rcvd) {
                connection_preface_settings_ack_rcvd = true;
            }
        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "received a new settings frame: updating connection settings and sending out SETTINGS ACK");
            }

            // if the INITIAL_WINDOW_SIZE has changed, need to change it for this streams, and all the other streams on this connection
            if (((FrameSettings) currentFrame).getInitialWindowSize() != -1) {
                int newSize = ((FrameSettings) currentFrame).getInitialWindowSize();
                muxLink.changeInitialWindowSizeAllStreams(newSize);
            }

            // update the SETTINGS for this connection
            muxLink.getRemoteConnectionSettings().updateSettings((FrameSettings) currentFrame);
            muxLink.getVirtualConnection().getStateMap().put("h2_frame_size", muxLink.getRemoteConnectionSettings().getMaxFrameSize());

            // immediately send out ACK (an empty SETTINGS frame with the ACK flag set)
            currentFrame = new FrameSettings(0, -1, -1, -1, -1, -1, -1, false);
            currentFrame.setAckFlag();

            try {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "processSETTINGSFrame:  stream: " + myID + " frame type: " + currentFrame.getFrameType().toString() + " direction: "
                                 + Direction.WRITING_OUT
                                 + " H2InboundLink hc: " + muxLink.hashCode());
                }

                writeFrameSync();

            } catch (FlowControlException e) {
                // FlowControlException cannot occur for FrameTypes.SETTINGS, so do nothing here but debug
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "writeSync caught (logically unexpected) FlowControlException: " + e);
                }
            }
        }

        // check to see if the current connection should be marked as initialized; if so, notify stream 1 to stop waiting
        if (connection_preface_settings_rcvd && connection_preface_settings_ack_rcvd) {
            if (muxLink.checkInitAndOpen()) {
                muxLink.initLock.countDown();
            }
        }

    }
1363793
public function wait(): void
    {
        while (!$this->stream->eof()) {
            $frame = $this->readFrame();

            if (null !== $frame) {
                if (!\is_array($frame)) {
                    $frame = [$frame];
                }

                foreach ($this->onNewFrameCallables as $newFrameCallable) {
                    \call_user_func_array($newFrameCallable, $frame);
                }
            }
        }
    }
226955
public function addFrame($frameName, IdFrame $frame)
    {
        $this->loadFrames();

        $this->frames[$frameName] = $frame;
        return $this;
    }
546336
public function render(Frame $frame)
    {
        global $_dompdf_debug;

        $this->_check_callbacks("begin_frame", $frame);

        if ($_dompdf_debug) {
            echo $frame;
            flush();
        }

        $style = $frame->get_style();

        if (in_array($style->visibility, array("hidden", "collapse"))) {
            return;
        }

        $display = $style->display;

        // Starts the CSS transformation
        if ($style->transform && is_array($style->transform)) {
            $this->_canvas->save();
            list($x, $y) = $frame->get_padding_box();
            $origin = $style->transform_origin;

            foreach ($style->transform as $transform) {
                list($function, $values) = $transform;
                if ($function === "matrix") {
                    $function = "transform";
                }

                $values = array_map("floatval", $values);
                $values[] = $x + (float)$style->length_in_pt($origin[0], (float)$style->length_in_pt($style->width));
                $values[] = $y + (float)$style->length_in_pt($origin[1], (float)$style->length_in_pt($style->height));

                call_user_func_array(array($this->_canvas, $function), $values);
            }
        }

        switch ($display) {

            case "block":
            case "list-item":
            case "inline-block":
            case "table":
            case "inline-table":
                $this->_render_frame("block", $frame);
                break;

            case "inline":
                if ($frame->is_text_node()) {
                    $this->_render_frame("text", $frame);
                } else {
                    $this->_render_frame("inline", $frame);
                }
                break;

            case "table-cell":
                $this->_render_frame("table-cell", $frame);
                break;

            case "table-row-group":
            case "table-header-group":
            case "table-footer-group":
                $this->_render_frame("table-row-group", $frame);
                break;

            case "-dompdf-list-bullet":
                $this->_render_frame("list-bullet", $frame);
                break;

            case "-dompdf-image":
                $this->_render_frame("image", $frame);
                break;

            case "none":
                $node = $frame->get_node();

                if ($node->nodeName === "script") {
                    if ($node->getAttribute("type") === "text/php" ||
                        $node->getAttribute("language") === "php"
                    ) {
                        // Evaluate embedded php scripts
                        $this->_render_frame("php", $frame);
                    } elseif ($node->getAttribute("type") === "text/javascript" ||
                        $node->getAttribute("language") === "javascript"
                    ) {
                        // Insert JavaScript
                        $this->_render_frame("javascript", $frame);
                    }
                }

                // Don't render children, so skip to next iter
                return;

            default:
                break;

        }

        // Starts the overflow: hidden box
        if ($style->overflow === "hidden") {
            list($x, $y, $w, $h) = $frame->get_padding_box();

            // get border radii
            $style = $frame->get_style();
            list($tl, $tr, $br, $bl) = $style->get_computed_border_radius($w, $h);

            if ($tl + $tr + $br + $bl > 0) {
                $this->_canvas->clipping_roundrectangle($x, $y, (float)$w, (float)$h, $tl, $tr, $br, $bl);
            } else {
                $this->_canvas->clipping_rectangle($x, $y, (float)$w, (float)$h);
            }
        }

        $stack = array();

        foreach ($frame->get_children() as $child) {
            // < 0 : nagative z-index
            // = 0 : no z-index, no stacking context
            // = 1 : stacking context without z-index
            // > 1 : z-index
            $child_style = $child->get_style();
            $child_z_index = $child_style->z_index;
            $z_index = 0;

            if ($child_z_index !== "auto") {
                $z_index = intval($child_z_index) + 1;
            } elseif ($child_style->float !== "none" || $child->is_positionned()) {
                $z_index = 1;
            }

            $stack[$z_index][] = $child;
        }

        ksort($stack);

        foreach ($stack as $by_index) {
            foreach ($by_index as $child) {
                $this->render($child);
            }
        }

        // Ends the overflow: hidden box
        if ($style->overflow === "hidden") {
            $this->_canvas->clipping_end();
        }

        if ($style->transform && is_array($style->transform)) {
            $this->_canvas->restore();
        }

        // Check for end frame callback
        $this->_check_callbacks("end_frame", $frame);
    }
286058
public static function dumpMask($frame)
    {
        $width = count($frame);
        for($y=0;$y<$width;$y++) {
            for($x=0;$x<$width;$x++) {
                echo ord($frame[$y][$x]).',';
            }
        }
    }