本文整理了Java中com.couchbase.client.deps.io.netty.buffer.ByteBuf.readShort()
方法的一些代码示例,展示了ByteBuf.readShort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.readShort()
方法的具体详情如下:
包路径:com.couchbase.client.deps.io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:readShort
[英]Gets a 16-bit short integer at the current readerIndexand increases the readerIndex by 2 in this buffer.
[中]获取当前readerIndex处的16位短整数,并在此缓冲区中将readerIndex增加2。
代码示例来源:origin: com.couchbase.client/core-io
@Override
public short readShort() {
return buf.readShort();
}
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
public short readShort() {
return buf.readShort();
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public short readShort() {
checkReadableBytes(2);
return buffer.readShort();
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public short readShort() {
return ByteBufUtil.swapShort(buf.readShort());
}
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
public short readShort() {
checkReadableBytes(2);
return buffer.readShort();
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public short readShort() throws IOException {
checkAvailable(2);
return buffer.readShort();
}
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
public short readShort() throws IOException {
checkAvailable(2);
return buffer.readShort();
}
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
public short readShort() {
return ByteBufUtil.swapShort(buf.readShort());
}
代码示例来源:origin: couchbase/java-dcp-client
private static int readSwappedUnsignedShort(ByteBuf in) {
return ByteBufUtil.swapShort(in.readShort()) & 0xFFFF;
}
代码示例来源:origin: couchbase/couchbase-jvm-core
/**
* Returns the closing status code as per <a href="http://tools.ietf.org/html/rfc6455#section-7.4">RFC 6455</a>. If
* a getStatus code is set, -1 is returned.
*/
public int statusCode() {
ByteBuf binaryData = content();
if (binaryData == null || binaryData.capacity() == 0) {
return -1;
}
binaryData.readerIndex(0);
int statusCode = binaryData.readShort();
binaryData.readerIndex(0);
return statusCode;
}
代码示例来源:origin: com.couchbase.client/core-io
/**
* Returns the closing status code as per <a href="http://tools.ietf.org/html/rfc6455#section-7.4">RFC 6455</a>. If
* a getStatus code is set, -1 is returned.
*/
public int statusCode() {
ByteBuf binaryData = content();
if (binaryData == null || binaryData.capacity() == 0) {
return -1;
}
binaryData.readerIndex(0);
int statusCode = binaryData.readShort();
binaryData.readerIndex(0);
return statusCode;
}
代码示例来源:origin: couchbase/java-dcp-client
ObserveSeqnoResponse(final ByteBuf response) {
ByteBuf content = MessageUtil.getContent(response);
this.didFailover = content.readBoolean();
this.vbid = content.readShort();
this.vbuuid = content.readLong();
this.persistSeqno = content.readLong();
this.currentSeqno = content.readLong();
this.oldVbuuid = this.didFailover ? content.readLong() : 0;
this.lastSeqno = this.didFailover ? content.readLong() : 0;
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
protected BinaryMemcacheRequest decodeHeader(ByteBuf in) {
BinaryMemcacheRequest header = new DefaultBinaryMemcacheRequest();
header.setMagic(in.readByte());
header.setOpcode(in.readByte());
header.setKeyLength(in.readShort());
header.setExtrasLength(in.readByte());
header.setDataType(in.readByte());
header.setReserved(in.readShort());
header.setTotalBodyLength(in.readInt());
header.setOpaque(in.readInt());
header.setCAS(in.readLong());
return header;
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
protected void channelRead0(ChannelHandlerContext ctx, FullBinaryMemcacheResponse msg) throws Exception {
List<ServerFeatures> supported = new ArrayList<ServerFeatures>();
ResponseStatus responseStatus = ResponseStatusConverter.fromBinary(msg.getStatus());
if (responseStatus.isSuccess()) {
while (msg.content().isReadable()) {
supported.add(ServerFeatures.fromValue(msg.content().readShort()));
}
} else {
LOGGER.debug("HELLO Negotiation did not succeed ({}).", responseStatus);
}
LOGGER.debug("Negotiated supported features: {}", supported);
ctx.fireUserEventTriggered(new ServerFeaturesEvent(supported));
originalPromise.setSuccess();
ctx.pipeline().remove(this);
ctx.fireChannelActive();
}
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
protected BinaryMemcacheRequest decodeHeader(ByteBuf in) {
BinaryMemcacheRequest header = new DefaultBinaryMemcacheRequest();
header.setMagic(in.readByte());
header.setOpcode(in.readByte());
header.setKeyLength(in.readShort());
header.setExtrasLength(in.readByte());
header.setDataType(in.readByte());
header.setReserved(in.readShort());
header.setTotalBodyLength(in.readInt());
header.setOpaque(in.readInt());
header.setCAS(in.readLong());
return header;
}
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
protected void channelRead0(ChannelHandlerContext ctx, FullBinaryMemcacheResponse msg) throws Exception {
List<ServerFeatures> supported = new ArrayList<ServerFeatures>();
ResponseStatus responseStatus = ResponseStatusConverter.fromBinary(msg.getStatus());
if (responseStatus.isSuccess()) {
while (msg.content().isReadable()) {
supported.add(ServerFeatures.fromValue(msg.content().readShort()));
}
} else {
LOGGER.debug("HELLO Negotiation did not succeed ({}).", responseStatus);
}
LOGGER.debug("Negotiated supported features: {}", supported);
ctx.fireUserEventTriggered(new ServerFeaturesEvent(supported));
originalPromise.setSuccess();
ctx.pipeline().remove(this);
ctx.fireChannelActive();
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
protected BinaryMemcacheResponse decodeHeader(ByteBuf in) {
BinaryMemcacheResponse header = new DefaultBinaryMemcacheResponse();
header.setMagic(in.readByte());
header.setOpcode(in.readByte());
if (header.getMagic() == FRAMING_MAGIC) {
header.setFramingExtrasLength(in.readByte());
header.setKeyLength(in.readByte());
} else {
header.setKeyLength(in.readShort());
}
header.setExtrasLength(in.readByte());
header.setDataType(in.readByte());
header.setStatus(in.readShort());
header.setTotalBodyLength(in.readInt());
header.setOpaque(in.readInt());
header.setCAS(in.readLong());
return header;
}
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
protected BinaryMemcacheResponse decodeHeader(ByteBuf in) {
BinaryMemcacheResponse header = new DefaultBinaryMemcacheResponse();
header.setMagic(in.readByte());
header.setOpcode(in.readByte());
if (header.getMagic() == FRAMING_MAGIC) {
header.setFramingExtrasLength(in.readByte());
header.setKeyLength(in.readByte());
} else {
header.setKeyLength(in.readShort());
}
header.setExtrasLength(in.readByte());
header.setDataType(in.readByte());
header.setStatus(in.readShort());
header.setTotalBodyLength(in.readInt());
header.setOpaque(in.readInt());
header.setCAS(in.readLong());
return header;
}
代码示例来源:origin: com.couchbase.client/core-io
/** */
protected void checkCloseFrameBody(
ChannelHandlerContext ctx, ByteBuf buffer) {
if (buffer == null || !buffer.isReadable()) {
return;
}
if (buffer.readableBytes() == 1) {
protocolViolation(ctx, "Invalid close frame body");
}
// Save reader index
int idx = buffer.readerIndex();
buffer.readerIndex(0);
// Must have 2 byte integer within the valid range
int statusCode = buffer.readShort();
if (statusCode >= 0 && statusCode <= 999 || statusCode >= 1004 && statusCode <= 1006
|| statusCode >= 1012 && statusCode <= 2999) {
protocolViolation(ctx, "Invalid close frame getStatus code: " + statusCode);
}
// May have UTF-8 message
if (buffer.isReadable()) {
try {
new Utf8Validator().check(buffer);
} catch (CorruptedFrameException ex) {
protocolViolation(ctx, ex);
}
}
// Restore reader index
buffer.readerIndex(idx);
}
代码示例来源:origin: couchbase/couchbase-jvm-core
/** */
protected void checkCloseFrameBody(
ChannelHandlerContext ctx, ByteBuf buffer) {
if (buffer == null || !buffer.isReadable()) {
return;
}
if (buffer.readableBytes() == 1) {
protocolViolation(ctx, "Invalid close frame body");
}
// Save reader index
int idx = buffer.readerIndex();
buffer.readerIndex(0);
// Must have 2 byte integer within the valid range
int statusCode = buffer.readShort();
if (statusCode >= 0 && statusCode <= 999 || statusCode >= 1004 && statusCode <= 1006
|| statusCode >= 1012 && statusCode <= 2999) {
protocolViolation(ctx, "Invalid close frame getStatus code: " + statusCode);
}
// May have UTF-8 message
if (buffer.isReadable()) {
try {
new Utf8Validator().check(buffer);
} catch (CorruptedFrameException ex) {
protocolViolation(ctx, ex);
}
}
// Restore reader index
buffer.readerIndex(idx);
}
内容来源于网络,如有侵权,请联系作者删除!