congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
TextWebSocketFrame
Code IndexAdd Tabnine to your IDE (free)

How to use
TextWebSocketFrame
in
io.netty.handler.codec.http.websocketx

Best Java code snippets using io.netty.handler.codec.http.websocketx.TextWebSocketFrame (Showing top 20 results out of 918)

Refine searchRefine arrow

  • ChannelHandlerContext
  • ByteBuf
  • Channel
  • BinaryWebSocketFrame
  • WebSocketFrame
  • ContinuationWebSocketFrame
origin: mrniko/netty-socketio

final ByteBuf out = encoder.allocateBuffer(ctx.alloc());
encoder.encodePacket(packet, out, ctx.alloc(), true);
WebSocketFrame res = new TextWebSocketFrame(out);
if (log.isTraceEnabled()) {
  log.trace("Out message: {} sessionId: {}", out.toString(CharsetUtil.UTF_8), msg.getSessionId());
if (out.isReadable()) {
  writeFutureList.add(ctx.channel().writeAndFlush(res));
} else {
  out.release();
    log.trace("Out attachment: {} sessionId: {}", ByteBufUtil.hexDump(outBuf), msg.getSessionId());
  writeFutureList.add(ctx.channel().writeAndFlush(new BinaryWebSocketFrame(outBuf)));
origin: lets-blade/blade

/**
 * Only supported TextWebSocketFrame
 *
 * @param ctx
 * @param frame
 */
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
  if (frame instanceof CloseWebSocketFrame) {
    this.handler.onDisConnect(this.context);
    this.handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
    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());
  }
  this.context.setReqText(((TextWebSocketFrame) frame).text());
  this.handler.onText(this.context);
}
origin: wildfly/wildfly

/**
 * Returns the text data in this frame
 */
public String text() {
  return content().toString(CharsetUtil.UTF_8);
}
origin: wildfly/wildfly

@Override
public TextWebSocketFrame replace(ByteBuf content) {
  return new TextWebSocketFrame(isFinalFragment(), rsv(), content);
}
origin: Netflix/zuul

ctx.writeAndFlush(new PongWebSocketFrame());
ctx.close();
final String text = tf.text();
logger.debug("received test frame: {}", text);
if (text != null && text.startsWith("ECHO ")) { //echo protocol
  ctx.channel().writeAndFlush(tf.copy());
origin: apache/activemq-artemis

LOG.trace("New data read: incoming: {}", message);
 FullHttpResponse response = (FullHttpResponse) message;
 throw new IllegalStateException(
   "Unexpected FullHttpResponse (getStatus=" + response.status() + ", content=" + response.content().toString(StandardCharsets.UTF_8) + ')');
if (frame instanceof TextWebSocketFrame) {
 TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
 LOG.warn("WebSocket Client received message: " + textFrame.text());
 ctx.fireExceptionCaught(new IOException("Received invalid frame over WebSocket."));
} else if (frame instanceof BinaryWebSocketFrame) {
 BinaryWebSocketFrame binaryFrame = (BinaryWebSocketFrame) frame;
 LOG.trace("WebSocket Client received data: {} bytes", binaryFrame.content().readableBytes());
 listener.onData(binaryFrame.content());
} else if (frame instanceof ContinuationWebSocketFrame) {
 ContinuationWebSocketFrame continuationFrame = (ContinuationWebSocketFrame) frame;
 LOG.trace("WebSocket Client received data continuation: {} bytes", continuationFrame.content().readableBytes());
 listener.onData(continuationFrame.content());
} else if (frame instanceof PingWebSocketFrame) {
 LOG.trace("WebSocket Client received ping, response with pong");
 ch.write(new PongWebSocketFrame(frame.content()));
} else if (frame instanceof CloseWebSocketFrame) {
 LOG.trace("WebSocket Client received closing");
 ch.close();
origin: Netflix/zuul

@Override
public ChannelFuture sendPushMessage(ChannelHandlerContext ctx, ByteBuf mesg) {
  final TextWebSocketFrame wsf = new TextWebSocketFrame(mesg);
  return ctx.channel().writeAndFlush(wsf);
}
origin: wildfly/wildfly

boolean readable = msg.content().isReadable();
decoder.writeInbound(msg.content().retain());
if (appendFrameTail(msg)) {
  decoder.writeInbound(Unpooled.wrappedBuffer(FRAME_TAIL));
CompositeByteBuf compositeUncompressedContent = ctx.alloc().compositeBuffer();
for (;;) {
  ByteBuf partUncompressedContent = decoder.readInbound();
    break;
  if (!partUncompressedContent.isReadable()) {
    partUncompressedContent.release();
    continue;
if (msg.isFinalFragment() && noContext) {
  cleanup();
  outMsg = new TextWebSocketFrame(msg.isFinalFragment(), newRsv(msg), compositeUncompressedContent);
} else if (msg instanceof BinaryWebSocketFrame) {
  outMsg = new BinaryWebSocketFrame(msg.isFinalFragment(), newRsv(msg), compositeUncompressedContent);
} else if (msg instanceof ContinuationWebSocketFrame) {
  outMsg = new ContinuationWebSocketFrame(msg.isFinalFragment(), newRsv(msg),
      compositeUncompressedContent);
} else {
origin: wildfly/wildfly

in.skipBytes(actualReadableBytes());
return;
    if (!in.isReadable()) {
      return;
    byte b = in.readByte();
    frameFinalFlag = (b & 0x80) != 0;
    frameRsv = (b & 0x70) >> 4;
      payloadBuffer = readBytes(ctx.alloc(), in, toFrameLength(framePayloadLength));
        out.add(new TextWebSocketFrame(frameFinalFlag, frameRsv, payloadBuffer));
        payloadBuffer = null;
        return;
      } else if (frameOpcode == OPCODE_BINARY) {
        out.add(new BinaryWebSocketFrame(frameFinalFlag, frameRsv, payloadBuffer));
        payloadBuffer = null;
        return;
      } else if (frameOpcode == OPCODE_CONT) {
        out.add(new ContinuationWebSocketFrame(frameFinalFlag, frameRsv,
            payloadBuffer));
        payloadBuffer = null;
origin: co.paralleluniverse/comsat-actors-netty

private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
  // Check for closing frame
  if (frame instanceof CloseWebSocketFrame) {
    handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
    return;
  }
  if (frame instanceof PingWebSocketFrame) {
    ctx.channel().writeAndFlush(new PongWebSocketFrame(frame.content().retain()));
    return;
  }
  if (frame instanceof ContinuationWebSocketFrame)
    return;
  if (frame instanceof TextWebSocketFrame)
    webSocketActor.onMessage(((TextWebSocketFrame) frame).text());
  else
    webSocketActor.onMessage(frame.content().nioBuffer());
}
origin: apsaltis/StreamingData-Book-Examples

@Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
  Channel channel = ctx.channel();
  if (!handshaker.isHandshakeComplete()) {
    throw new IllegalStateException(
        "Unexpected FullHttpResponse (getStatus=" + response.status() +
            ", content=" + response.content().toString(CharsetUtil.UTF_8) + ')');
    final byte[] messagePayload = new byte[textFrame.content().readableBytes()];
    textFrame.content().readBytes(messagePayload);
    channel.close();
    rsvpProducer.close();
origin: jamesdbloom/mockserver

private void handleWebSocketFrame(final ChannelHandlerContext ctx, WebSocketFrame frame) throws JsonProcessingException {
  if (frame instanceof CloseWebSocketFrame) {
    handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain()).addListener(new ChannelFutureListener() {
      public void operationComplete(ChannelFuture future) {
        clientRegistry.remove(ctx);
      }
    });
  } else if (frame instanceof TextWebSocketFrame) {
    try {
      HttpRequest httpRequest = httpRequestSerializer.deserialize(((TextWebSocketFrame) frame).text());
      clientRegistry.put(ctx, httpRequest);
      sendUpdate(httpRequest, ctx);
    } catch (IllegalArgumentException iae) {
      sendMessage(ctx, ImmutableMap.<String, Object>of("error", iae.getMessage()));
    }
  } else if (frame instanceof PingWebSocketFrame) {
    ctx.write(new PongWebSocketFrame(frame.content().retain()));
  } else {
    throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass().getName()));
  }
}
origin: org.zbus/zbus

private Message decodeWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
  // Check for closing frame
  if (frame instanceof CloseWebSocketFrame) {
    handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
    return null;
  }
  
  if (frame instanceof PingWebSocketFrame) {
    ctx.write(new PongWebSocketFrame(frame.content().retain()));
    return null;
  }
  
  if (frame instanceof TextWebSocketFrame) {
    TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
    return parseMessage(textFrame.content());
  }
  
  if (frame instanceof BinaryWebSocketFrame) {
    BinaryWebSocketFrame binFrame = (BinaryWebSocketFrame) frame;
    return parseMessage(binFrame.content());
  }
  
  log.warn("Message format error: " + frame); 
  return null;
}
 
origin: ballerina-platform/ballerina-lang

@Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
  Channel ch = ctx.channel();
  if (!handshaker.isHandshakeComplete()) {
    handshaker.finishHandshake(ch, (FullHttpResponse) msg);
    LOGGER.debug("WebSocket Client connected!");
    handshakeFuture.setSuccess();
    return;
  }
  if (msg instanceof FullHttpResponse) {
    FullHttpResponse response = (FullHttpResponse) msg;
    throw new IllegalStateException("Unexpected FullHttpResponse (getStatus=" + response.status() +
        ", content=" + response.content().toString(CharsetUtil.UTF_8) + ')');
  }
  WebSocketFrame frame = (WebSocketFrame) msg;
  if (frame instanceof TextWebSocketFrame) {
    TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
    LOGGER.debug("WebSocket Client received text message: " + textFrame.text());
    String textReceived = textFrame.text();
    callback.call(textReceived);
  } else if (frame instanceof CloseWebSocketFrame) {
    isConnected = false;
    LOGGER.debug("WebSocket Client received closing");
    ch.close();
  }
}
origin: wildfly/wildfly

private WebSocketFrame decodeTextFrame(ChannelHandlerContext ctx, ByteBuf buffer) {
  int ridx = buffer.readerIndex();
  int rbytes = actualReadableBytes();
  int delimPos = buffer.indexOf(ridx, ridx + rbytes, (byte) 0xFF);
  if (delimPos == -1) {
  ByteBuf binaryData = readBytes(ctx.alloc(), buffer, frameSize);
  buffer.skipBytes(1);
  int ffDelimPos = binaryData.indexOf(binaryData.readerIndex(), binaryData.writerIndex(), (byte) 0xFF);
  return new TextWebSocketFrame(binaryData);
origin: wso2/msf4j

@Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
  Channel ch = ctx.channel();
  if (!handshaker.isHandshakeComplete()) {
    handshaker.finishHandshake(ch, (FullHttpResponse) msg);
    throw new IllegalStateException(
        "Unexpected FullHttpResponse (getStatus=" + response.status() +
        ", content=" + response.content().toString(CharsetUtil.UTF_8) + ')');
  if (frame instanceof TextWebSocketFrame) {
    TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
    logger.debug("WebSocket Client received text message: " + textFrame.text());
    textReceived = textFrame.text();
  } else if (frame instanceof BinaryWebSocketFrame) {
    BinaryWebSocketFrame binaryFrame = (BinaryWebSocketFrame) frame;
    bufferReceived = binaryFrame.content().nioBuffer();
    logger.debug("WebSocket Client received  binary message: " + bufferReceived.toString());
  } else if (frame instanceof PongWebSocketFrame) {
    logger.debug("WebSocket Client received pong");
    PongWebSocketFrame pongFrame = (PongWebSocketFrame) frame;
    bufferReceived = pongFrame.content().nioBuffer();
  } else if (frame instanceof CloseWebSocketFrame) {
    logger.debug("WebSocket Client received closing");
    ch.close();
origin: org.jboss.aerogear/aerogear-netty-codec-sockjs

@SuppressWarnings("resource")
public static String[] decode(final TextWebSocketFrame frame) throws IOException {
  final ByteBuf content = frame.content();
  if (content.readableBytes() == 0) {
    return EMPTY_STRING_ARRAY;
  }
  final ByteBufInputStream byteBufInputStream = new ByteBufInputStream(content);
  final byte firstByte = content.getByte(0);
  if (firstByte == '[') {
    return MAPPER.readValue(byteBufInputStream, String[].class);
  } else if (firstByte == '{') {
    return new String[] { content.toString(CharsetUtil.UTF_8) };
  } else {
    return new String[] { MAPPER.readValue(byteBufInputStream, String.class) };
  }
}
origin: io.termd/termd-core

@Override
protected void write(byte[] buffer) {
 ByteBuf byteBuf = Unpooled.buffer();
 byteBuf.writeBytes(buffer);
 context.writeAndFlush(new TextWebSocketFrame(byteBuf));
}
origin: jooby-project/jooby

public void handle(final Object msg) {
 ready();
 if (msg instanceof TextWebSocketFrame) {
  onTextCallback.accept(((TextWebSocketFrame) msg).text());
 } else if (msg instanceof BinaryWebSocketFrame) {
  onBinaryCallback.accept(((BinaryWebSocketFrame) msg).content().nioBuffer());
 } else if (msg instanceof CloseWebSocketFrame) {
  CloseWebSocketFrame closeFrame = ((CloseWebSocketFrame) msg).retain();
  int statusCode = closeFrame.statusCode();
  onCloseCallback.accept(statusCode == -1 ? WebSocket.NORMAL.code() : statusCode,
    Optional.ofNullable(closeFrame.reasonText()));
  handshaker.close(ctx.channel(), closeFrame).addListener(CLOSE);
 } else if (msg instanceof Throwable) {
  onErrorCallback.accept((Throwable) msg);
 }
}
origin: normanmaurer/netty-in-action

@Override
public void userEventTriggered(ChannelHandlerContext ctx,
  Object evt) throws Exception {
  if (evt == WebSocketServerProtocolHandler
     .ServerHandshakeStateEvent.HANDSHAKE_COMPLETE) {
    ctx.pipeline().remove(HttpRequestHandler.class);
    group.writeAndFlush(new TextWebSocketFrame(
        "Client " + ctx.channel() + " joined"));
    group.add(ctx.channel());
  } else {
    super.userEventTriggered(ctx, evt);
  }
}
io.netty.handler.codec.http.websocketxTextWebSocketFrame

Javadoc

Web Socket text frame

Most used methods

  • <init>
    Creates a new text frame with the specified text string. The final fragment flag is set to true.
  • text
    Returns the text data in this frame
  • content
  • isFinalFragment
  • fromText
  • retain
  • rsv
  • copy
  • getText
  • release

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • requestLocationUpdates (LocationManager)
  • getSharedPreferences (Context)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • IsNull (org.hamcrest.core)
    Is the value null?
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now