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


Java ChannelBuffer.writeShort方法代码示例

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


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

示例1: sendResponse

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
private static void sendResponse(Channel channel, int device, long id, int crc) {
    if (channel != null) {
        ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
        response.writeByte(device);
        response.writeByte(MSG_ACK);
        response.writeInt((int) id);
        response.writeShort(crc);
        response.writeShort(Checksum.crc16(
                Checksum.CRC16_XMODEM, response.toByteBuffer()));

        ChannelBuffer encoded = ChannelBuffers.dynamicBuffer();
        encoded.writeByte(0x01); // header
        while (response.readable()) {
            int b = response.readByte();
            if (b == 0x01 || b == 0x04 || b == 0x10 || b == 0x11 || b == 0x13) {
                encoded.writeByte(0x10);
                b += 0x20;
            }
            encoded.writeByte(b);
        }
        encoded.writeByte(0x04); // ending
        channel.write(encoded);
    }
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:25,代码来源:MxtProtocolDecoder.java

示例2: encodeContent

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
private ChannelBuffer encodeContent(String content) {

        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();

        buf.writeByte(0x67);
        buf.writeByte(0x67);
        buf.writeByte(EelinkProtocolDecoder.MSG_DOWNLINK);
        buf.writeShort(2 + 1 + 4 + content.length()); // length
        buf.writeShort(0); // index

        buf.writeByte(0x01); // command
        buf.writeInt(0); // server id
        buf.writeBytes(content.getBytes(StandardCharsets.UTF_8));

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

示例3: sendResponse

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
private void sendResponse(Channel channel, int type, int index) {
    if (channel != null) {
        ChannelBuffer response = ChannelBuffers.buffer(7);
        response.writeByte(0x67); response.writeByte(0x67); // header
        response.writeByte(type);
        response.writeShort(2); // length
        response.writeShort(index);
        channel.write(response);
    }
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:11,代码来源:EelinkProtocolDecoder.java

示例4: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
    int iStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    c.writeShort(VALUE_LENGTH);
    c.writeInt(rawValue);
    return c.writerIndex() - iStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:NexthopIPv4addressTlv.java

示例5: sendResponse

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
private static void sendResponse(Channel channel, ChannelBuffer buf) {
    if (channel != null) {
        ChannelBuffer response = ChannelBuffers.directBuffer(4);
        response.writeByte('*');
        response.writeShort(buf.getUnsignedShort(buf.writerIndex() - 2));
        response.writeByte(buf.getUnsignedByte(buf.writerIndex() - 3));
        channel.write(response);
    }
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:10,代码来源:OrionProtocolDecoder.java

示例6: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
    int iLenStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    c.writeShort(hLength);
    c.writeBytes(rawValue);
    return c.writerIndex() - iLenStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:OpaqueNodePropertiesSubTlv.java

示例7: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
    int iLenStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    c.writeShort(LENGTH);
    c.writeInt(msd);
    return c.writerIndex() - iLenStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:SrPceCapabilityTlv.java

示例8: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
    int iLenStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    c.writeShort(LENGTH);
    c.writeInt(routerID);
    c.writeInt(drInterface.toInt());
    return c.writerIndex() - iLenStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:OspfPseudonode.java

示例9: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
    int tlvStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    int tlvLenIndex = c.writerIndex();
    hLength = 0;
    c.writeShort(hLength);

    ListIterator<PcepValueType> listIterator = llLinkDescriptorsSubTLVs.listIterator();

    while (listIterator.hasNext()) {
        PcepValueType tlv = listIterator.next();

        tlv.write(c);

        // need to take care of padding
        int pad = tlv.getLength() % 4;

        if (0 != pad) {
            pad = 4 - pad;
            for (int i = 0; i < pad; ++i) {
                c.writeByte((byte) 0);
            }
        }
    }

    hLength = (short) (c.writerIndex() - tlvStartIndex);
    c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));

    return c.writerIndex() - tlvStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:LinkDescriptorsTlv.java

示例10: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
    int iLenStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    c.writeShort(LENGTH);
    c.writeInt(rawValue);
    return c.writerIndex() - iLenStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:IPv4InterfaceAddressSubTlv.java

示例11: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
    int iLenStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    c.writeShort(LENGTH);
    if (isRawValueSet) {
        c.writeInt(rawValue);
    } else {
        int temp = 0;
        if (bUFlag) {
            temp = temp | UFLAG_SET;
        }
        if (bSFlag) {
            temp = temp | SFLAG_SET;
        }
        if (bIFlag) {
            temp = temp | IFLAG_SET;
        }
        if (bTFlag) {
            temp = temp | TFLAG_SET;
        }
        if (bDFlag) {
            temp = temp | DFLAG_SET;
        }
        c.writeInt(temp);
    }
    return c.writerIndex() - iLenStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:StatefulPceCapabilityTlv.java

示例12: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {

    int tlvStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    int tlvLenIndex = c.writerIndex();
    hLength = 0;
    c.writeShort(hLength);

    ListIterator<PcepValueType> listIterator = llRemoteTENodeDescriptorSubTLVs.listIterator();

    while (listIterator.hasNext()) {
        PcepValueType tlv = listIterator.next();

        if (tlv == null) {
            log.debug("TLV is null from subTlv list");
            continue;
        }
        tlv.write(c);

        // need to take care of padding
        int pad = tlv.getLength() % 4;

        if (0 != pad) {
            pad = 4 - pad;
            for (int i = 0; i < pad; ++i) {
                c.writeByte((byte) 0);
            }
        }
    }

    hLength = (short) (c.writerIndex() - tlvStartIndex);
    c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));

    return c.writerIndex() - tlvStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:37,代码来源:RemoteNodeDescriptorsTlv.java

示例13: formatMessage

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
public static ChannelBuffer formatMessage(int type, ChannelBuffer id, ChannelBuffer data) {
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    buf.writeByte(0x7e);
    buf.writeShort(type);
    buf.writeShort(data.readableBytes());
    buf.writeBytes(id);
    buf.writeShort(1); // index
    buf.writeBytes(data);
    buf.writeByte(Checksum.xor(buf.toByteBuffer(1, buf.readableBytes() - 1)));
    buf.writeByte(0x7e);
    return buf;
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:13,代码来源:HuabaoProtocolDecoder.java

示例14: write

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer c) {
    int iLenStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    c.writeShort(LENGTH);
    c.writeInt(routerID);
    return c.writerIndex() - iLenStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:OspfNonPseudonode.java

示例15: encodeCommand

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
@Override
protected Object encodeCommand(Command command) {

    ChannelBuffer content = ChannelBuffers.dynamicBuffer();

    switch (command.getType()) {
        case Command.TYPE_POSITION_SINGLE:
            return encodeContent(command.getDeviceId(), MSG_TRACK_ON_DEMAND, content);
        case Command.TYPE_POSITION_PERIODIC:
            content.writeShort(command.getInteger(Command.KEY_FREQUENCY) / 10);
            return encodeContent(command.getDeviceId(), MSG_TRACK_BY_INTERVAL, content);
        case Command.TYPE_ENGINE_STOP:
            content.writeByte(0x01);
            return encodeContent(command.getDeviceId(), MSG_OUTPUT_CONTROL, content);
        case Command.TYPE_ENGINE_RESUME:
            content.writeByte(0x00);
            return encodeContent(command.getDeviceId(), MSG_OUTPUT_CONTROL, content);
        case Command.TYPE_ALARM_GEOFENCE:
            content.writeShort(command.getInteger(Command.KEY_RADIUS));
            return encodeContent(command.getDeviceId(), MSG_MOVEMENT_ALARM, content);
        case Command.TYPE_SET_TIMEZONE:
            int offset = TimeZone.getTimeZone(command.getString(Command.KEY_TIMEZONE)).getRawOffset() / 60000;
            content.writeBytes(String.valueOf(offset).getBytes(StandardCharsets.US_ASCII));
            return encodeContent(command.getDeviceId(), MSG_TIME_ZONE, content);
        case Command.TYPE_REBOOT_DEVICE:
            return encodeContent(command.getDeviceId(), MSG_REBOOT_GPS, content);
        default:
            Log.warning(new UnsupportedOperationException(command.getType()));
            break;
    }

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


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