Only supported TextWebSocketFrame

@param ctx
@param frame
769235
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
        if (frame instanceof CloseWebSocketFrame) {
            this.handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
            CompletableFuture.completedFuture(new WebSocketContext(this.session,this.handler))
                    .thenAcceptAsync(this.handler::onDisConnect);
            return;
        }
        if (frame instanceof PingWebSocketFrame) {
            ctx.channel().write(new PongWebSocketFrame(frame.content().retain()));
            return;
        }

        if (!(frame instanceof TextWebSocketFrame)) {
            throw new UnsupportedOperationException("unsupported frame type: " + frame.getClass().getName());
        }
        CompletableFuture.completedFuture(new WebSocketContext(this.session,this.handler,((TextWebSocketFrame) frame).text()))
                .thenAcceptAsync(this.handler::onText,ctx.executor());
    }
1120994
protected void setFrameIndex (int fidx)
    {
        _fidx = fidx;
        _bounds.width = _frames.getWidth(_fidx);
        _bounds.height = _frames.getHeight(_fidx);
    }
1254377
public final WebsocketSender websocket(String subprotocols, int maxFramePayloadLength) {
		Objects.requireNonNull(subprotocols, "subprotocols");
		TcpClient tcpConfiguration = tcpConfiguration()
				.bootstrap(b -> HttpClientConfiguration.websocketSubprotocols(b, subprotocols))
				.bootstrap(b -> HttpClientConfiguration.websocketMaxFramePayloadLength(b, maxFramePayloadLength));
		return new WebsocketFinalizer(tcpConfiguration);
	}
825576
@Override
  public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
      throws Exception {
    if (msg instanceof SendGrpcFrameCommand) {
      sendGrpcFrame(ctx, (SendGrpcFrameCommand) msg, promise);
    } else if (msg instanceof SendResponseHeadersCommand) {
      sendResponseHeaders(ctx, (SendResponseHeadersCommand) msg, promise);
    } else if (msg instanceof CancelServerStreamCommand) {
      cancelStream(ctx, (CancelServerStreamCommand) msg, promise);
    } else if (msg instanceof ForcefulCloseCommand) {
      forcefulClose(ctx, (ForcefulCloseCommand) msg, promise);
    } else {
      AssertionError e =
          new AssertionError("Write called for unexpected type: " + msg.getClass().getName());
      ReferenceCountUtil.release(msg);
      promise.setFailure(e);
      throw e;
    }
  }
1109170
public void switchToFrame(T iframe) {
        getTargetLocator().frame(iframe);
        setCurrentContext(null);
        currentIFramePath.add(iframe);
    }
109898
private static void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception {
        Http2FrameStream stream = data.stream();

        if (data.isEndStream()) {
            sendResponse(ctx, stream, data.content());
        } else {
            // We do not send back the response to the remote-peer, so we need to release it.
            data.release();
        }

        // Update the flowcontroller
        ctx.write(new DefaultHttp2WindowUpdateFrame(data.initialFlowControlledBytes()).stream(stream));
    }
1281494
public void onMessage(Mtp2Buffer rxFrame, Mtp2 mtp2) {
        // | ----------------------- TO L4 --------------------------- |
        // | --------------------- SIF ------------------------ |
        // FSN BSN LEN SIO DPC/OPC,SLS HEADING LEN
        // b1 b0 0e 01 01 80 00 00 21 70 01 02 03 04 05 06 0f CRC CRC
        int sio = rxFrame.frame[3] & 0xFF;
        int subserviceIndicator = (sio >> 4) & 0x0F;
        int serviceIndicator = sio & 0x0F;
        int ni = (subserviceIndicator & 0x0C); // local NI(network Indicator) form msg., 0x0C, since we store it as shifted
                                               // value.
        // int dpc = (sif[0] & 0xff | ((sif[1] & 0x3f) << 8));
        // int opc = ((sif[1] & 0xC0) >> 6) | ((sif[2] & 0xff) << 2) | ((sif[3]
        // & 0x0f) << 10);
        // int sls = (sif[3] & 0xf0) >>> 4;
        int dpc = dpc(rxFrame.frame, 4); // 1 - cause sif contains sio, even though its also passed as arg.
        int opc = opc(rxFrame.frame, 4);
        int sls = sls(rxFrame.frame, 4);

        // check SSI, Q.704 Figure 25, seems like if its bad, we discard.
        if (this.ni != ni) {
            if (logger.isEnabledFor(Level.ERROR)) {
                logger.error(String.format("(%s) Received MSSU with bad SSI, discarding! ni:" + ni + " thisni:" + this.ni
                        + " [si=" + serviceIndicator + ",ssi=" + subserviceIndicator + ", dpc=" + dpc + ", opc=" + opc
                        + ", sls=" + sls + "] data: ", mtp2.getName())
                        + Arrays.toString(rxFrame.frame));
            }
            return;
        }

        switch (serviceIndicator) {
            case LINK_MANAGEMENT:
                int h0 = rxFrame.frame[8] & 0x0f;
                int h1 = (rxFrame.frame[8] & 0xf0) >>> 4;

                if (logger.isDebugEnabled()) {
                    logger.debug(String.format("(%s) Signalling network management", mtp2.getName()));
                }

                if (h0 == 0) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Changeover management", mtp2.getName()));
                    }
                } else if (h0 == 7 && h1 == 1) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) TRA received", mtp2.getName()));
                    }
                }
                // FIX ME
                break;
            case LINK_TESTING:
                h0 = rxFrame.frame[8] & 0x0f;
                h1 = (rxFrame.frame[8] & 0xf0) >>> 4;

                int len = (rxFrame.frame[9] & 0xf0) >>> 4;
                if (h0 == 1 && h1 == 1) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Received SLTM", mtp2.getName()));
                    }
                    // receive SLTM from remote end
                    // create response

                    // change order of opc/dpc in SLTA !
                    writeRoutingLabel(this.localFrame, sio, this.ni, sls, opc, dpc);
                    // slta[0] = (byte) sio;
                    this.localFrame[5] = 0x021;
                    // +1 cause we copy LEN byte also.
                    System.arraycopy(rxFrame.frame, 9, this.localFrame, 6, len + 1);

                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Responding with SLTA", mtp2.getName()));
                    }
                    mtp2.send(this.localFrame, len + 9);
                } else if (h0 == 1 && h1 == 2) {
                    // receive SLTA from remote end
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Received SLTA", mtp2.getName()));
                    }

                    // checking pattern
                    if (checkPattern(rxFrame, len, SLTM_PATTERN)) {
                        // test message is acknowledged
                        mtp2.sltmTest.ack();

                        // notify top layer that link is up
                        if (!l4IsUp) {
                            l4IsUp = true;
                            linkUp(mtp2);
                        }
                    } else {
                        if (logger.isEnabledFor(Level.WARN)) {
                            logger.warn("SLTA pattern does not match: \n" + Arrays.toString(rxFrame.frame) + "\n"
                                    + Arrays.toString(SLTM_PATTERN));
                        }
                    }
                } else {
                    if (logger.isEnabledFor(Level.WARN)) {
                        logger.warn(String.format("(%s) Unexpected message type", mtp2.getName()));
                    }
                }
                break;
            case _SI_SERVICE_SCCP:
                if (logger.isDebugEnabled()) {
                    logger.debug("Received SCCP MSU");
                }

                if (mtp3Listener != null) {

                    // | ----------------------- TO L4 --------------------------- |
                    // | --------------------- SIF ------------------------ |
                    // FSN BSN LEN SIO DPC/OPC,SLS HEADING LEN
                    // b1 b0 0e 01 01 80 00 00 21 70 01 02 03 04 05 06 0f CRC CRC
                    byte[] messageBuffer = new byte[rxFrame.len - 5]; // -5 = FSN(1) + BSN(1) + LEN(1) +2xCRC(1)
                    System.arraycopy(rxFrame.frame, 3, messageBuffer, 0, rxFrame.len - 5);
                    // messageBuffer[0] = (byte) sio;
                    try {
                        mtp3Listener.receive(messageBuffer);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                break;
            case _SI_SERVICE_ISUP:
                if (logger.isDebugEnabled()) {
                    logger.debug("Received ISUP MSU");

                }
                if (mtp3Listener != null) {
                    byte[] messageBuffer = new byte[rxFrame.len - 5];
                    System.arraycopy(rxFrame.frame, 3, messageBuffer, 0, rxFrame.len - 5);
                    // messageBuffer[0] = (byte) sio;
                    try {
                        mtp3Listener.receive(messageBuffer);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                break;
            default:
                if (logger.isEnabledFor(Level.WARN)) {
                    logger.warn("Received MSU for UNKNOWN SERVICE!!!!!!!!!!!: " + Utils.dump(rxFrame.frame, rxFrame.len, false));
                }
                break;
        }
    }
67615
public void setWebAppDispatcherContext(IWebAppDispatcherContext ctx) {
        // 321485
        if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)){  //306998.15
            logger.logp(Level.FINE, CLASS_NAME,"setWebAppDispatcherContext", " old context [" + this.getDispatchContext() + "] new context [" + ctx +"]");
        }
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        SRTServletRequestThreadData.getInstance().setDispatchContext(ctx);
        this._dispatchContext = (WebAppDispatcherContext) ctx;
        resetPathElements();
    }
510447
public static WebSocketFrame createTextFrame(String payload)
    {
        return new WebSocketFrame()
            .setFin(true)
            .setOpcode(TEXT)
            .setPayload(payload);
    }
269648
protected ChannelFuture handleHandshake(ChannelHandlerContext ctx, NettyHttpRequest req, WebSocketBean<?> webSocketBean, MutableHttpResponse<?> response) {
        int maxFramePayloadLength = webSocketBean.messageMethod().flatMap(m -> m.getValue(OnMessage.class, "maxPayloadLength", Integer.class)).orElse(65536);
        WebSocketServerHandshakerFactory wsFactory =
                new WebSocketServerHandshakerFactory(
                        getWebSocketURL(ctx, req),
                        null,
                        true,
                        maxFramePayloadLength
                );
        handshaker = wsFactory.newHandshaker(req.getNativeRequest());
        MutableHttpHeaders headers = response.getHeaders();
        io.netty.handler.codec.http.HttpHeaders nettyHeaders;
        if (headers instanceof NettyHttpHeaders) {
            nettyHeaders = ((NettyHttpHeaders) headers).getNettyHeaders();
        } else {
            nettyHeaders = new DefaultHttpHeaders();
            for (Map.Entry<String, List<String>> entry : headers) {
                nettyHeaders.add(entry.getKey(), entry.getValue());
            }
        }
        Channel channel = ctx.channel();
        if (handshaker == null) {
            return WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(channel);
        } else {
            return handshaker.handshake(
                    channel,
                    req.getNativeRequest(),
                    nettyHeaders,
                    channel.newPromise()
            );
        }
    }
247170
private void verifyReservedBit1(WebSocketFrame frame) throws WebSocketException
    {
        // If a per-message compression extension has been agreed.
        if (mPMCE != null)
        {
            // Verify the RSV1 bit using the rule described in RFC 7692.
            boolean verified = verifyReservedBit1ForPMCE(frame);

            if (verified)
            {
                return;
            }
        }

        if (frame.getRsv1() == false)
        {
            // No problem.
            return;
        }

        // The RSV1 bit of a frame is set unexpectedly.
        throw new WebSocketException(
            WebSocketError.UNEXPECTED_RESERVED_BIT, "The RSV1 bit of a frame is set unexpectedly.");
    }
835623
private void signalObjectSuccess(WebContext ctx) {
        log.log(ctx.getRequest().method().name(),
                ctx.getRequestedURI(),
                APILog.Result.OK,
                CallContext.getCurrent().getWatch());
    }
281212
@Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
        if (msg instanceof Http2DataFrame) {
            Http2DataFrame dataFrame = (Http2DataFrame) msg;
            encoder().writeData(ctx, dataFrame.stream().id(), dataFrame.content(),
                    dataFrame.padding(), dataFrame.isEndStream(), promise);
        } else if (msg instanceof Http2HeadersFrame) {
            writeHeadersFrame(ctx, (Http2HeadersFrame) msg, promise);
        } else if (msg instanceof Http2WindowUpdateFrame) {
            Http2WindowUpdateFrame frame = (Http2WindowUpdateFrame) msg;
            Http2FrameStream frameStream = frame.stream();
            // It is legit to send a WINDOW_UPDATE frame for the connection stream. The parent channel doesn't attempt
            // to set the Http2FrameStream so we assume if it is null the WINDOW_UPDATE is for the connection stream.
            try {
                if (frameStream == null) {
                    increaseInitialConnectionWindow(frame.windowSizeIncrement());
                } else {
                    consumeBytes(frameStream.id(), frame.windowSizeIncrement());
                }
                promise.setSuccess();
            } catch (Throwable t) {
                promise.setFailure(t);
            }
        } else if (msg instanceof Http2ResetFrame) {
            Http2ResetFrame rstFrame = (Http2ResetFrame) msg;
            encoder().writeRstStream(ctx, rstFrame.stream().id(), rstFrame.errorCode(), promise);
        } else if (msg instanceof Http2PingFrame) {
            Http2PingFrame frame = (Http2PingFrame) msg;
            encoder().writePing(ctx, frame.ack(), frame.content(), promise);
        } else if (msg instanceof Http2SettingsFrame) {
            encoder().writeSettings(ctx, ((Http2SettingsFrame) msg).settings(), promise);
        } else if (msg instanceof Http2SettingsAckFrame) {
            // In the event of manual SETTINGS ACK is is assumed the encoder will apply the earliest received but not
            // yet ACKed settings.
            encoder().writeSettingsAck(ctx, promise);
        } else if (msg instanceof Http2GoAwayFrame) {
            writeGoAwayFrame(ctx, (Http2GoAwayFrame) msg, promise);
        } else if (msg instanceof Http2UnknownFrame) {
            Http2UnknownFrame unknownFrame = (Http2UnknownFrame) msg;
            encoder().writeFrame(ctx, unknownFrame.frameType(), unknownFrame.stream().id(),
                    unknownFrame.flags(), unknownFrame.content(), promise);
        } else if (!(msg instanceof Http2Frame)) {
            ctx.write(msg, promise);
        } else {
            ReferenceCountUtil.release(msg);
            throw new UnsupportedMessageTypeException(msg);
        }
    }
168585
public void processCompleteFrame() throws Http2Exception {
        Frame currentFrame = getCurrentFrame();

        boolean frameSizeError = false;
        try {
            currentFrame.processPayload(this);
        } catch (Http2Exception e) {
            // If we get an error here, it should be safe to assume that this frame doesn't have the expected byte count,
            // which must be treated as an error of type FRAME_SIZE_ERROR.  If we're processing a DATA or PRIORITY frame, then
            // we can treat the error as a stream error rather than a connection error.
            if (!e.isConnectionError()) {
                frameSizeError = true;
            } else {
                // this is a connection error; we need to send a GOAWAY on the connection
                throw e;
            }
        } catch (Exception e) {
            throw new ProtocolException("Error processing the payload for " + currentFrame.getFrameType()
                                        + " frame on stream " + currentFrame.getStreamId());
        }

        // call the stream processor to process this stream. For now, don't return from here until the
        // frame has been fully processed.
        int streamId = currentFrame.getStreamId();
        H2StreamProcessor stream = muxLink.getStream(streamId);

        if (stream == null) {
            if ((streamId != 0) && (streamId % 2 == 0)) {
                if (currentFrame.getFrameType().equals(FrameTypes.PRIORITY)) {
                    // ignore PRIORITY frames in any state
                    return;
                } else if (currentFrame.getFrameType().equals(FrameTypes.RST_STREAM) && streamId < muxLink.getHighestClientStreamId()) {
                    // tolerate RST_STREAM frames that are sent on closed push streams
                    return;
                } else {
                    throw new ProtocolException("Cannot start a stream from the client with an even numbered ID. stream-id: " + streamId);
                }
            } else {
                stream = startNewInboundSession(streamId);
            }
        }
        if (frameSizeError) {
            currentFrame = new FrameRstStream(streamId, 4, (byte) 0, false, FrameDirection.READ);
            ((FrameRstStream) currentFrame).setErrorCode(Constants.FRAME_SIZE_ERROR);
        }

        stream.processNextFrame(currentFrame, Direction.READ_IN);
    }
429440
@Override
	protected void decode(ChannelHandlerContext paramChannelHandlerContext,
			WebSocketFrame paramINBOUND_IN, List<Object> paramList)
			throws Exception {
		if(paramINBOUND_IN instanceof BinaryWebSocketFrame)
		{
			BinaryWebSocketFrame msg=(BinaryWebSocketFrame)paramINBOUND_IN;
			ByteBuf data = msg.content();
			paramList.add(data);
			data.retain();
		}
	}
112342
public WebDriver innerFrame(String... frames) {
    delegate.defaultContent();

    for (String frame : frames) {
      try {
        String selector = String.format("frame#%1$s,frame[name=%1$s],iframe#%1$s,iframe[name=%1$s]", frame);
        Wait().until(frameToBeAvailableAndSwitchToIt_fixed(By.cssSelector(selector)));
      }
      catch (NoSuchElementException | TimeoutException e) {
        throw new NoSuchFrameException("No frame found with id/name = " + frame, e);
      }
    }

    return webDriver;
  }
1258218
private static void onHeadersRead(ChannelHandlerContext ctx, Http2HeadersFrame headers)
            throws Exception {
        if (headers.isEndStream()) {
            ByteBuf content = ctx.alloc().buffer();
            content.writeBytes(RESPONSE_BYTES.duplicate());
            ByteBufUtil.writeAscii(content, " - via HTTP/2");
            sendResponse(ctx, content);
        }
    }