當前位置: 首頁>>代碼示例>>Java>>正文


Java BinaryWebSocketFrame.content方法代碼示例

本文整理匯總了Java中io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame.content方法的典型用法代碼示例。如果您正苦於以下問題:Java BinaryWebSocketFrame.content方法的具體用法?Java BinaryWebSocketFrame.content怎麽用?Java BinaryWebSocketFrame.content使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame的用法示例。


在下文中一共展示了BinaryWebSocketFrame.content方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: decode

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext ctx,
		BinaryWebSocketFrame wsFrame, List<Object> out) throws Exception {
	ByteBuf buf = wsFrame.content();

	this.messageNewDecoder.decode(ctx, buf, out);
}
 
開發者ID:osswangxining,項目名稱:mqttserver,代碼行數:8,代碼來源:MqttMessageWebSocketFrameDecoder.java

示例2: decode

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
/**
 * 將webSocket消息轉換為bytebuf類型,以適配後麵的解碼器
 */
@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();
	}
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:16,代碼來源:WebSocketBinaryFrameByteBufAdapter.java

示例3: decode

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext chc, BinaryWebSocketFrame frame, List<Object> out) throws Exception
{
    //convert the frame to a ByteBuf
    ByteBuf bb = frame.content();
    bb.retain();
    out.add(bb);
}
 
開發者ID:sylvek,項目名稱:websocket-mqtt-forwarder,代碼行數:9,代碼來源:Server.java

示例4: decode

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext chc, BinaryWebSocketFrame frame, List<Object> out) throws Exception {
    //convert the frame to a ByteBuf
    ByteBuf bb = frame.content();
    //System.out.println("WebSocketFrameToByteBufDecoder decode - " + ByteBufUtil.hexDump(bb));
    bb.retain();
    out.add(bb);
}
 
開發者ID:sn3009,項目名稱:EasyMessage,代碼行數:9,代碼來源:NettyAcceptor.java

示例5: decode

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
@Override
protected void decode(final ChannelHandlerContext channelHandlerContext, final BinaryWebSocketFrame frame, final List<Object> objects) throws Exception {
    final ByteBuf messageBytes = frame.content();
    final byte len = messageBytes.readByte();
    if (len <= 0) {
        objects.add(RequestMessage.INVALID);
        return;
    }

    final ByteBuf contentTypeBytes = channelHandlerContext.alloc().buffer(len);
    try {
        messageBytes.readBytes(contentTypeBytes);
        final String contentType = contentTypeBytes.toString(UTF8);
        final MessageSerializer serializer = select(contentType, Serializers.DEFAULT_REQUEST_SERIALIZER);

        // it's important to re-initialize these channel attributes as they apply globally to the channel. in
        // other words, the next request to this channel might not come with the same configuration and mixed
        // state can carry through from one request to the next
        channelHandlerContext.channel().attr(StateKey.SESSION).set(null);
        channelHandlerContext.channel().attr(StateKey.SERIALIZER).set(serializer);
        channelHandlerContext.channel().attr(StateKey.USE_BINARY).set(true);

        try {
            objects.add(serializer.deserializeRequest(messageBytes.discardReadBytes()));
        } catch (SerializationException se) {
            objects.add(RequestMessage.INVALID);
        }
    } finally {
        contentTypeBytes.release();
    }
}
 
開發者ID:PKUSilvester,項目名稱:LiteGraph,代碼行數:32,代碼來源:WsGremlinBinaryRequestDecoder.java

示例6: decode

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext chc, BinaryWebSocketFrame frame, List<Object> out)
    throws Exception {
  //convert the frame to a ByteBuf
  ByteBuf bb = frame.content();
  //System.out.println("WebSocketFrameToByteBufDecoder decode - " + ByteBufUtil.hexDump(bb));
  bb.retain();
  out.add(bb);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:cloud-pubsub-mqtt-proxy,代碼行數:10,代碼來源:NettyAcceptor.java

示例7: notifyBinaryMessage

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
private void notifyBinaryMessage(BinaryWebSocketFrame binaryWebSocketFrame) throws ServerConnectorException {
    ByteBuf byteBuf = binaryWebSocketFrame.content();
    boolean finalFragment = binaryWebSocketFrame.isFinalFragment();
    ByteBuffer byteBuffer = byteBuf.nioBuffer();
    WebSocketMessageImpl webSocketBinaryMessage =
            new WebSocketBinaryMessageImpl(byteBuffer, finalFragment);
    webSocketBinaryMessage = setupCommonProperties(webSocketBinaryMessage);
    connectorFuture.notifyWSListener((WebSocketBinaryMessage) webSocketBinaryMessage);
}
 
開發者ID:wso2,項目名稱:carbon-transports,代碼行數:10,代碼來源:WebSocketSourceHandler.java

示例8: notifyBinaryMessage

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
private void notifyBinaryMessage(BinaryWebSocketFrame binaryWebSocketFrame, ChannelHandlerContext ctx)
        throws ServerConnectorException {
    ByteBuf byteBuf = binaryWebSocketFrame.content();
    boolean finalFragment = binaryWebSocketFrame.isFinalFragment();
    ByteBuffer byteBuffer = byteBuf.nioBuffer();
    WebSocketMessageImpl webSocketBinaryMessage =
            new WebSocketBinaryMessageImpl(byteBuffer, finalFragment);
    webSocketBinaryMessage = setupCommonProperties(webSocketBinaryMessage, ctx);
    connectorListener.onMessage((WebSocketBinaryMessage) webSocketBinaryMessage);
}
 
開發者ID:wso2,項目名稱:carbon-transports,代碼行數:11,代碼來源:WebSocketTargetHandler.java

示例9: decode

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext ctx, BinaryWebSocketFrame msg, List<Object> out) throws Exception {
    ByteBuf in = msg.content();
    int id = in.readUnsignedByte();
    Packet packet = Packets.createClientPacket(id);
    packet.read(new ByteBufPacketStream(in));
    out.add(packet);
}
 
開發者ID:Thinkofname,項目名稱:ThinkMap,代碼行數:9,代碼來源:PacketDecoder.java

示例10: decode

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext chc, BinaryWebSocketFrame frame, List<Object> out)
        throws Exception {
    // convert the frame to a ByteBuf
    ByteBuf bb = frame.content();
    // System.out.println("WebSocketFrameToByteBufDecoder decode - " +
    // ByteBufUtil.hexDump(bb));
    bb.retain();
    out.add(bb);
}
 
開發者ID:andsel,項目名稱:moquette,代碼行數:11,代碼來源:NettyAcceptor.java

示例11: decode

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext chc, BinaryWebSocketFrame frame, List<Object> out) throws Exception {
    //convert the frame to a ByteBuf
    ByteBuf bb = frame.content();
    out.add(bb);
}
 
開發者ID:kevoree,項目名稱:kevoree-library,代碼行數:7,代碼來源:NettyAcceptor.java

示例12: extractBytes

import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; //導入方法依賴的package包/類
private byte[] extractBytes(Object msg) {
  BinaryWebSocketFrame frame = (BinaryWebSocketFrame) msg;

  ByteBuf buf = frame.content();

  byte[] b = new byte[buf.readableBytes()];

  buf.readBytes(b);

  return b;
}
 
開發者ID:mrstampy,項目名稱:gameboot,代碼行數:12,代碼來源:WebSocketHandler.java


注:本文中的io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame.content方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。