本文整理汇总了Java中io.vertx.core.buffer.Buffer.getByteBuf方法的典型用法代码示例。如果您正苦于以下问题:Java Buffer.getByteBuf方法的具体用法?Java Buffer.getByteBuf怎么用?Java Buffer.getByteBuf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.getByteBuf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onParse
import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
protected void onParse(Buffer buffer) {
switch (status) {
case TCP_HEADER:
ByteBuf buf = buffer.getByteBuf();
if (!firstNEqual(TCP_MAGIC, buf.array(), TCP_MAGIC.length)) {
reset();
return;
}
buf.skipBytes(TCP_MAGIC.length);
msgId = buf.readLong();
totalLen = buf.readInt();
headerLen = buf.readInt();
if (totalLen == 0) {
onReadOnePackage(null, null);
return;
}
parser.fixedSizeMode(totalLen);
status = ParseStatus.TCP_PAYLOAD;
break;
case TCP_PAYLOAD:
Buffer headerBuffer = buffer.slice(0, headerLen);
Buffer bodyBuffer = buffer.slice(headerLen, buffer.length());
onReadOnePackage(headerBuffer, bodyBuffer);
break;
default:
break;
}
}
示例2: decodeResponse
import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
default Object decodeResponse(Buffer buffer, JavaType type) throws Exception {
if (buffer.length() == 0) {
return null;
}
try (BufferInputStream input = new BufferInputStream(buffer.getByteBuf())) {
return doDecodeResponse(input, type);
}
}
示例3: getBytesFast
import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
public static byte[] getBytesFast(Buffer buffer) {
ByteBuf byteBuf = buffer.getByteBuf();
return getBytesFast(byteBuf);
}
示例4: testUnsupportedMethod
import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testUnsupportedMethod() {
final Buffer a = Symbol.newSymbol(Buffer.class);
a.getByteBuf();
}