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


Java ByteBuf.getUnsignedByte方法代码示例

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


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

示例1: getUnadjustedFrameLength

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
/**
 * Decodes the specified region of the buffer into an unadjusted frame length.  The default implementation is
 * capable of decoding the specified region into an unsigned 8/16/24/32/64 bit integer.  Override this method to
 * decode the length field encoded differently.  Note that this method must not modify the state of the specified
 * buffer (e.g. {@code readerIndex}, {@code writerIndex}, and the content of the buffer.)
 *
 * @throws DecoderException
 *         if failed to decode the specified region
 */
protected long getUnadjustedFrameLength(ByteBuf buf, int offset, int length, ByteOrder order) {
    buf = buf.order(order);
    long frameLength;
    switch (length) {
        case 1:
            frameLength = buf.getUnsignedByte(offset);
            break;
        case 2:
            frameLength = buf.getUnsignedShort(offset);
            break;
        case 3:
            frameLength = buf.getUnsignedMedium(offset);
            break;
        case 4:
            frameLength = buf.getUnsignedInt(offset);
            break;
        case 8:
            frameLength = buf.getLong(offset);
            break;
        default:
            throw new DecoderException(
                    "unsupported lengthFieldLength: " + lengthFieldLength + " (expected: 1, 2, 3, 4, or 8)");
    }
    return frameLength;
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:35,代码来源:LengthFieldBasedFrameDecoder.java

示例2: decode

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {

    // 프로토콜 확인을 위해서 5byte를 확인한다.
    if (in.readableBytes() < 5) {
        // 다음 inbound 시 버퍼에 이전에 전송된 내용이 쌓이므로 버퍼를 비운다.
        in.clear();
        return;
    }

    if (isSsl(in)) {
        enableSsl(ctx);
    } else {

        if (!isUnificationMode) {
            switchToBinary(ctx);
            return;
        }

        final int magicPacket1 = in.getUnsignedByte(in.readerIndex());
        final int magicPacket2 = in.getUnsignedByte(in.readerIndex() + 1);

        if (isHttp(magicPacket1, magicPacket2)) {
            switchToHttp(ctx);
        } else {
            switchToBinary(ctx);
        }
    }
}
 
开发者ID:veritasware,项目名称:neto,代码行数:30,代码来源:ProtocolUnificationHandler.java

示例3: decode

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
protected void decode ( final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out ) throws Exception
{
    if ( logger.isTraceEnabled () )
    {
        logger.trace ( "decode - bytes: {}", ByteBufUtil.hexDump ( in ) );
    }

    if ( in.readableBytes () < Constants.APCI_MIN_LENGTH )
    {
        return;
    }

    final byte start = in.getByte ( in.readerIndex () + 0 );
    if ( start != Constants.START_BYTE )
    {
        throw new DecoderException ( String.format ( "ACPI must start with 0x%02x but did with 0x%02x", Constants.START_BYTE, start ) );
    }

    final short len = in.getUnsignedByte ( in.readerIndex () + 1 );

    if ( len > Constants.APCI_MAX_DATA_LENGTH )
    {
        throw new DecoderException ( String.format ( "APCI has a maximum length of %s bytes, but we received %s", Constants.APCI_MAX_DATA_LENGTH, len ) );
    }

    if ( in.readableBytes () < len + 2 )
    {
        return;
    }

    // we have the full InformationTransfer

    // skip start & len
    in.skipBytes ( 2 );

    // read control fields
    final ByteBuf controlFields = in.readSlice ( 4 );

    final ByteBuf data;
    if ( len > 4 )
    {
        data = Unpooled.copiedBuffer ( in.readSlice ( len - 4 ) ).order ( ByteOrder.LITTLE_ENDIAN );
    }
    else
    {
        data = null;
    }

    // now add the PDU

    out.add ( decode ( controlFields, data ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:54,代码来源:APDUDecoder.java

示例4: toArray

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public int[] toArray ()
{
    final ByteBuf buf = Unpooled.buffer ( 4 );
    buf.writeMedium ( this.address );
    return new int[] { buf.getUnsignedByte ( 0 ), buf.getUnsignedByte ( 1 ), buf.getUnsignedByte ( 2 ) };
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:7,代码来源:InformationObjectAddress.java

示例5: toArray

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public int[] toArray ()
{
    final ByteBuf buf = Unpooled.buffer ( 2 );
    buf.writeShort ( this.address );
    return new int[] { buf.getUnsignedByte ( 0 ), buf.getUnsignedByte ( 1 ) };
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:7,代码来源:ASDUAddress.java


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