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


Java ChannelBuffer.readBytes方法代码示例

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


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

示例1: messageReceived

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
  if (e.getMessage() instanceof ChannelBuffer) {
    ChannelBuffer buffer = (ChannelBuffer) e.getMessage();

    int bytesToRead = Math.min(currentChunkSize - bytesRead, buffer.readableBytes());
    buffer.readBytes(getMailEnvelope().getMessageOutputStream(), bytesToRead);
    bytesRead += bytesToRead;

    if (bytesRead == currentChunkSize) {
      stopCapturingData();
    }

    return;
  }

  super.messageReceived(ctx, e);
}
 
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:19,代码来源:ChunkingExtension.java

示例2: pcepUpdateMsgTest9

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
 * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject) objects in PcUpd message.
 */
@Test
public void pcepUpdateMsgTest9() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
            0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
            (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
            (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
            0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x01, 0x04, 0x00 };

    byte[] testupdateMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepUpdateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testupdateMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testupdateMsg = new byte[readLen];
    buf.readBytes(testupdateMsg, 0, readLen);

    assertThat(testupdateMsg, is(updateMsg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:41,代码来源:PcepUpdateMsgTest.java

示例3: read

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * Read from channel buffer and Returns BGP header.
 *
 * @param cb ChannelBuffer
 * @return object of BGPHeader
 */
public static BgpHeader read(ChannelBuffer cb) {

    byte[] marker = new byte[MARKER_LENGTH];
    byte type;
    short length;
    cb.readBytes(marker, 0, MARKER_LENGTH);
    length = cb.readShort();
    type = cb.readByte();
    return new BgpHeader(marker, length, type);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:BgpHeader.java

示例4: pcepUpdateMsgTest32

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * This test case checks for SRP, LSP,
 * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
 */
@Test
public void pcepUpdateMsgTest32() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
            0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x20, 0x10, 0x00, 0x8, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x01, 0x04, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
            0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object

    byte[] testupdateMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepUpdateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testupdateMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testupdateMsg = new byte[readLen];
    buf.readBytes(testupdateMsg, 0, readLen);

    assertThat(testupdateMsg, is(updateMsg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:39,代码来源:PcepUpdateMsgTest.java

示例5: readFrom

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public void readFrom(ChannelBuffer channelBuffer) {
    while (channelBuffer.readableBytes() > 0) {
        int addressLength = channelBuffer.readByte();
        byte[] addressbytes = new byte[addressLength];
        channelBuffer.readBytes(addressbytes, 0, addressLength);
        String areaAddress = IsisUtil.areaAddres(addressbytes);
        this.areaAddress.add(areaAddress);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:AreaAddressTlv.java

示例6: reportMessageTest26

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
 * ERO Object,LSPA Object
 * in PcRpt message.
 */
@Test
public void reportMessageTest26() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x58,
            0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
            0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
            (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
            (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
            0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
            0x07, 0x10, 0x00, 0x14, //ERO Object
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA Object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

    byte[] testReportMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(reportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepReportMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);

    int readLen = buf.writerIndex();
    testReportMsg = new byte[readLen];
    buf.readBytes(testReportMsg, 0, readLen);

    assertThat(testReportMsg, is(reportMsg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:41,代码来源:PcepReportMsgTest.java

示例7: reportMessageTest27

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv)
 * ERO Object
 * in PcRpt message.
 */
@Test
public void reportMessageTest27() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x44,
            0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
            0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
            (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
            (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
            0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
            0x07, 0x10, 0x00, 0x14, //ERO Object
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};

    byte[] testReportMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(reportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepReportMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);

    int readLen = buf.writerIndex();
    testReportMsg = new byte[readLen];
    buf.readBytes(testReportMsg, 0, readLen);

    assertThat(testReportMsg, is(reportMsg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:39,代码来源:PcepReportMsgTest.java

示例8: pcepUpdateMsgTest18

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
 * ERO (IPv4SubObject, IPv4SubObject),Metric objects in PcUpd message.
 */
@Test
public void pcepUpdateMsgTest18() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
            0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
            (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
            (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x01, 0x04, 0x00,
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object

    byte[] testupdateMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepUpdateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testupdateMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testupdateMsg = new byte[readLen];
    buf.readBytes(testupdateMsg, 0, readLen);

    assertThat(testupdateMsg, is(updateMsg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:39,代码来源:PcepUpdateMsgTest.java

示例9: readFrom

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * Reads from channel buffer and populate instance.
 *
 * @param channelBuffer channelBuffer instance
 * @throws OspfParseException might throws exception while parsing buffer
 */
public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {

    try {
        byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
        channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
        this.setNetworkMask(Ip4Address.valueOf(tempByteArray));

        while (channelBuffer.readableBytes() >= OspfUtil.EXTERNAL_DESTINATION_LENGTH) {
            OspfExternalDestination externalDestination = new OspfExternalDestination();

            //E Bit - use to find type1 or type2
            int eIsSet = channelBuffer.readByte();
            if (eIsSet != 0) {
                externalDestination.setType1orType2Metric(true);
            } else {
                externalDestination.setType1orType2Metric(false);
            }
            externalDestination.setMetric(channelBuffer.readUnsignedMedium());
            tempByteArray = new byte[OspfUtil.FOUR_BYTES];
            channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
            externalDestination.setForwardingAddress(Ip4Address.valueOf(tempByteArray));
            externalDestination.setExternalRouterTag(channelBuffer.readInt());

            this.addExternalDestination(externalDestination);
        }
    } catch (Exception e) {
        log.debug("Error::ExternalLSA:: {}", e.getMessage());
        throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:37,代码来源:ExternalLsa.java

示例10: readFrom

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public void readFrom(ChannelBuffer channelBuffer) {
    this.setAdjacencyType(channelBuffer.readByte());
    this.setLocalCircuitId(channelBuffer.readInt());
    if (channelBuffer.readableBytes() > 0) {
        byte[] tempByteArray = new byte[IsisUtil.ID_SIX_BYTES];
        channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_SIX_BYTES);
        this.setNeighborSystemId(IsisUtil.systemId(tempByteArray));
        this.setNeighborLocalCircuitId(channelBuffer.readInt());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:AdjacencyStateTlv.java

示例11: openMessageTest16

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * This test case checks open object with LSR id encoded.
 */
@Test
public void openMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18, // common header
            0x01, 0x10, 0x00, 0x14, // common object header
            0x20, 0x05, 0x1E, 0x01, // OPEN object
            (byte) 0xFF, 0x05, 0x00, 0x08, // Node attribute TLV
            0x00, 0x11, 0x00, 0x04,  // PCEP-LS-IPv4-ROUTER-ID sub tlv
            0x02, 0x02, 0x02, 0x02
    };

    byte[] testOpenMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(openMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepOpenMsg.class));

    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testOpenMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testOpenMsg = new byte[readLen];
    buf.readBytes(testOpenMsg, 0, readLen);
    assertThat(testOpenMsg, is(openMsg));

}
 
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:PcepOpenMsgTest.java

示例12: read

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * Reads from channel buffer and return object of PcepIroObject.
 *
 * @param cb of type channel buffer
 * @return object of PcepIroObject
 * @throws PcepParseException while parsing from channel buffer
 */
public static PcepIroObject read(ChannelBuffer cb) throws PcepParseException {

    PcepObjectHeader iroObjHeader;
    LinkedList<PcepValueType> llSubObjects;

    iroObjHeader = PcepObjectHeader.read(cb);

    //take only IroObject buffer.
    ChannelBuffer tempCb = cb.readBytes(iroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
    llSubObjects = parseSubObjects(tempCb);
    return new PcepIroObjectVer1(iroObjHeader, llSubObjects);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:PcepIroObjectVer1.java

示例13: openMessageTest10

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV
 * in Pcep Open message.
 */
@Test
public void openMessageTest10() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1C, // common header
            0x01, 0x10, 0x00, 0x18, // common object header
            0x20, 0x05, 0x1E, 0x01, // OPEN object
            0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
            0x00, 0x00, 0x00, 0x05,
            0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
            0x00, 0x00, 0x00, 0x00};

    byte[] testOpenMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(openMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepOpenMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testOpenMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testOpenMsg = new byte[readLen];
    buf.readBytes(testOpenMsg, 0, readLen);

    assertThat(testOpenMsg, is(openMsg));

}
 
开发者ID:shlee89,项目名称:athena,代码行数:37,代码来源:PcepOpenMsgTest.java

示例14: getOspfHeader

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
/**
 * Gets the OSPF packet Header.
 *
 * @param channelBuffer channel buffer instance.
 * @return Ospf Header instance.
 */
private OspfPacketHeader getOspfHeader(ChannelBuffer channelBuffer) throws Exception {
    OspfPacketHeader ospfPacketHeader = new OspfPacketHeader();

    // Determine OSPF version & Packet Type
    int version = channelBuffer.readByte(); //byte 1 is ospf version
    int packetType = channelBuffer.readByte(); //byte 2 is ospf packet type

    // byte 3 & 4 combine is packet length.
    int packetLength = channelBuffer.readShort();

    byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
    channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
    Ip4Address routerId = Ip4Address.valueOf(tempByteArray);

    tempByteArray = new byte[OspfUtil.FOUR_BYTES];
    channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
    Ip4Address areaId = Ip4Address.valueOf(tempByteArray);

    int checkSum = channelBuffer.readUnsignedShort();
    int auType = channelBuffer.readUnsignedShort();
    int authentication = (int) channelBuffer.readLong();

    ospfPacketHeader.setOspfVer(version);
    ospfPacketHeader.setOspftype(packetType);
    ospfPacketHeader.setOspfPacLength(packetLength);
    ospfPacketHeader.setRouterId(routerId);
    ospfPacketHeader.setAreaId(areaId);
    ospfPacketHeader.setChecksum(checkSum);
    ospfPacketHeader.setAuthType(auType);
    ospfPacketHeader.setAuthentication(authentication);

    return ospfPacketHeader;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:40,代码来源:OspfMessageReader.java

示例15: decode

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
protected Object decode(
        ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {

    if (buf.readableBytes() < 10) {
        return null;
    }

    if (Character.isDigit(buf.getByte(buf.readerIndex()))) {
        int length = 4 + Integer.parseInt(buf.toString(buf.readerIndex(), 4, StandardCharsets.US_ASCII));
        if (buf.readableBytes() >= length) {
            return buf.readBytes(length);
        }
    } else {
        while (buf.getByte(buf.readerIndex()) == '\r' || buf.getByte(buf.readerIndex()) == '\n') {
            buf.skipBytes(1);
        }
        int delimiter = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("\r\n"));
        if (delimiter == -1) {
            delimiter = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '!');
        }
        if (delimiter != -1) {
            ChannelBuffer result = buf.readBytes(delimiter - buf.readerIndex());
            buf.skipBytes(1);
            return result;
        }
    }

    return null;
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:31,代码来源:MegastekFrameDecoder.java


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