當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。