当前位置: 首页>>代码示例>>Java>>正文


Java ByteBuf.readCharSequence方法代码示例

本文整理汇总了Java中io.netty.buffer.ByteBuf.readCharSequence方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuf.readCharSequence方法的具体用法?Java ByteBuf.readCharSequence怎么用?Java ByteBuf.readCharSequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.buffer.ByteBuf的用法示例。


在下文中一共展示了ByteBuf.readCharSequence方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processProtocolInitFrame

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private void processProtocolInitFrame(ByteBuf buffer, List<Object> out) {
    if (buffer.readableBytes() >= 8) {
        CharSequence protocolName = buffer.readCharSequence(4, CharsetUtil.US_ASCII);
        buffer.skipBytes(1);
        byte majorVersion = buffer.readByte();
        byte minorVersion = buffer.readByte();
        byte revision = buffer.readByte();

        if (!AMQP_PROTOCOL_IDENTIFIER.equals(protocolName)) {
            out.add(new AmqpBadMessage(new IllegalArgumentException("Unknown protocol name " +
                                                                           protocolName.toString())));
            currentState = State.BAD_MESSAGE;
        }

        out.add(new ProtocolInitFrame(majorVersion, minorVersion, revision));
    }
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:18,代码来源:AmqpDecoder.java

示例2: decodeText

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public Number decodeText(int len, ByteBuf buff) {
  // Todo optimize that
  CharSequence cs = buff.readCharSequence(len, StandardCharsets.UTF_8);
  BigDecimal big = new BigDecimal(cs.toString());
  // julien : that does not seem consistent to either return a Double or BigInteger
  if (big.scale() == 0) {
    return big.toBigInteger();
  } else {
    // we might loose precision here
    return big.doubleValue();
  }
}
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:14,代码来源:DataType.java

示例3: decode

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
protected ClusterMessage decode(ByteBuf in) {
    in.markReaderIndex();
    try {
        ClusterMessage hdr = new ClusterMessage();
        hdr.signature = (String) in.readCharSequence(4, UTF_8);
        hdr.length = in.readInt();
        if (in.readableBytes() < hdr.length - 8) {
            in.resetReaderIndex(); return null;
        }
        hdr.version = Version.valueOf(in.readUnsignedShort());
        if (hdr.version == PROTOCOL_V0) decodeMessageV0(hdr, in);
        else if (hdr.version == PROTOCOL_V1) decodeMessageV1(hdr, in);
        else throw new UnsupportedOperationException("version: " + hdr.version);
        return hdr;
    } catch (Exception e) {
        in.resetReaderIndex(); return null;
    }
}
 
开发者ID:leonchen83,项目名称:redis-cluster-watchdog,代码行数:19,代码来源:ClusterMessageDecoder.java

示例4: read

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void read(RakNetByteBuf in) {
    super.read(in);
    protocolVersion = in.readInt();
    edition = in.readUnsignedByte();

    ByteBuf buf = in.readBytes(
            in.readUnsignedVarInt()
    );

    chainData = buf.readCharSequence(buf.readIntLE(), Charsets.UTF_8);
    skinData = buf.readCharSequence(buf.readIntLE(), Charsets.UTF_8);
    buf.release();
}
 
开发者ID:MagicDroidX,项目名称:RakNetty,代码行数:15,代码来源:LoginPacket.java

示例5: processOption

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private String processOption(ChannelHandlerContext ctx, ByteBuf in) throws IOException {
     switch (currentOption) {
         case Protocol.NBD_OPT_EXPORT_NAME:
             CharSequence exportName = in.readCharSequence((int) currentOptionLen, Charset.forName("UTF-8"));

             if (!exportProvider.supportsClientFlags(clientFlags)) {
                 LOGGER.error("client flags {} not supported", clientFlags);
                 ctx.channel().close();
                 break;
             }

             long exportSize = 0;
             if ((exportSize = exportProvider.open(exportName)) < 0) {
                 // ep us unwilling to export this name
                 ctx.channel().close();
                 break;
             }

/* build response */
             ByteBuf resp = ctx.alloc().buffer(256);
             resp.writeLong(exportSize);
             short transmissionFlags =
                     Protocol.NBD_FLAG_HAS_FLAGS
                             | Protocol.NBD_FLAG_SEND_FLUSH
                             | Protocol.NBD_FLAG_SEND_TRIM;
             resp.writeShort(transmissionFlags);

             if ((clientFlags & Protocol.NBD_FLAG_NO_ZEROES) == 0) {
                 resp.writeZero(124);
             }
             ctx.writeAndFlush(resp);

             //FIXME: transfer any remaining bytes into the transmission phase!
         /* The NBD protocol has two phases: the handshake (HS_) and the transmission (TM_) */
             // Handshake complete, switch to transmission phase
             ctx.pipeline().addLast("transmission", new TransmissionPhase(config, exportProvider));
             ctx.pipeline().remove(this);
             return exportName.toString();

         default:
             sendHandshakeOptionHagglingReply(ctx, currentOption, Protocol.NBD_REP_ERR_UNSUP, null);
     }
     return null;
 }
 
开发者ID:MineboxOS,项目名称:minebox,代码行数:45,代码来源:HandshakePhase.java


注:本文中的io.netty.buffer.ByteBuf.readCharSequence方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。