本文整理匯總了Java中org.jboss.netty.buffer.ChannelBuffer.getShort方法的典型用法代碼示例。如果您正苦於以下問題:Java ChannelBuffer.getShort方法的具體用法?Java ChannelBuffer.getShort怎麽用?Java ChannelBuffer.getShort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jboss.netty.buffer.ChannelBuffer
的用法示例。
在下文中一共展示了ChannelBuffer.getShort方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readFromBuffer
import org.jboss.netty.buffer.ChannelBuffer; //導入方法依賴的package包/類
/**
* Reads from ISIS packet from buffer.
*
* @param channelBuffer buffer
* @return ISIS message
* @throws Exception exception
*/
public IsisMessage readFromBuffer(ChannelBuffer channelBuffer) throws Exception {
int dataLength = channelBuffer.readableBytes();
log.debug("IsisMessageReader::readFromBuffer Data length {}", dataLength);
if (channelBuffer.readableBytes() < IsisConstants.PDU_LENGTH) {
log.debug("Packet should have minimum length...");
throw new IsisParseException(IsisErrorType.MESSAGE_HEADER_ERROR, IsisErrorType.BAD_MESSAGE_LENGTH);
}
IsisHeader isisHeader = getIsisHeader(channelBuffer);
int totalLength = 0;
IsisMessage isisMessage = null;
switch (isisHeader.isisPduType()) {
case L1HELLOPDU:
case L2HELLOPDU:
isisMessage = new L1L2HelloPdu(isisHeader);
totalLength = channelBuffer.getShort(IsisConstants.PDULENGTHPOSITION);
break;
case P2PHELLOPDU:
isisMessage = new P2PHelloPdu(isisHeader);
totalLength = channelBuffer.getShort(IsisConstants.PDULENGTHPOSITION);
break;
case L1LSPDU:
case L2LSPDU:
isisMessage = new LsPdu(isisHeader);
totalLength = channelBuffer.getShort(8);
break;
case L1CSNP:
case L2CSNP:
isisMessage = new Csnp(isisHeader);
totalLength = channelBuffer.getShort(8);
break;
case L1PSNP:
case L2PSNP:
isisMessage = new Psnp(isisHeader);
totalLength = channelBuffer.getShort(8);
break;
default:
log.debug("Message Reader[Decoder] - Unknown PDU type..!!!");
break;
}
if (isisMessage != null) {
try {
int bodyLength = totalLength - IsisConstants.COMMONHEADERLENGTH;
isisMessage.readFrom(channelBuffer.readBytes(bodyLength));
} catch (Exception e) {
throw new IsisParseException(IsisErrorType.ISIS_MESSAGE_ERROR,
IsisErrorType.BAD_MESSAGE);
}
}
return isisMessage;
}