本文整理匯總了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);
}
示例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();
}
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}