本文整理了Java中io.vertx.core.buffer.Buffer.getByteBuf()
方法的一些代码示例,展示了Buffer.getByteBuf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.getByteBuf()
方法的具体详情如下:
包路径:io.vertx.core.buffer.Buffer
类名称:Buffer
方法名:getByteBuf
[英]Returns the Buffer as a Netty ByteBuf.
The returned buffer is a duplicate.
The returned ByteBuf might have its readerIndex > 0This method is meant for internal use only.
[中]以Netty ByteBuf的形式返回缓冲区。
返回的缓冲区是重复的。
返回的ByteBuf可能具有readerIndex>0此方法仅供内部使用。
代码示例来源:origin: eclipse-vertx/vert.x
public Buffer appendBuffer(Buffer buff) {
buffer.writeBytes(buff.getByteBuf());
return this;
}
代码示例来源:origin: eclipse-vertx/vert.x
public Buffer appendBuffer(Buffer buff, int offset, int len) {
ByteBuf byteBuf = buff.getByteBuf();
int from = byteBuf.readerIndex() + offset;
buffer.writeBytes(byteBuf, from, len);
return this;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public WebSocketFrame pongFrame(Buffer data) {
return new WebSocketFrameImpl(FrameType.PONG, data.getByteBuf(), true);
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public NetSocket write(Buffer message, Handler<AsyncResult<Void>> handler) {
writeMessage(message.getByteBuf(), handler);
return this;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public HttpServerResponseImpl write(Buffer chunk) {
ByteBuf buf = chunk.getByteBuf();
return write(buf);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public HttpClientRequestImpl write(Buffer chunk) {
ByteBuf buf = chunk.getByteBuf();
write(buf, false);
return this;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public HttpServerResponse write(Buffer chunk) {
ByteBuf buf = chunk.getByteBuf();
return write(buf);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public NetSocket write(Buffer data) {
write(data.getByteBuf());
return this;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public NetSocket write(Buffer data) {
synchronized (conn) {
writeData(data.getByteBuf(), false);
return this;
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public NetSocket write(Buffer message, Handler<AsyncResult<Void>> handler) {
synchronized (conn) {
conn.handler.writeData(stream, message.getByteBuf(), false, handler);
return this;
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public void end(Buffer buffer) {
synchronized (conn) {
writeData(buffer.getByteBuf(), true);
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public synchronized HttpClientRequest writeCustomFrame(int type, int flags, Buffer payload) {
HttpClientStream s;
synchronized (this) {
checkComplete();
if ((s = stream) == null) {
throw new IllegalStateException("Not yet connected");
}
}
s.writeFrame(type, flags, payload.getByteBuf());
return this;
}
代码示例来源:origin: eclipse-vertx/vert.x
public Buffer setBuffer(int pos, Buffer b, int offset, int len) {
ensureWritable(pos, len);
ByteBuf byteBuf = b.getByteBuf();
buffer.setBytes(pos, byteBuf, byteBuf.readerIndex() + offset, len);
return this;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public int readFromBuffer(int pos, Buffer buffer) {
int len = buffer.getInt(pos);
Buffer b = buffer.getBuffer(pos + 4, pos + 4 + len);
this.buffer = b.getByteBuf();
return pos + 4 + len;
}
}
代码示例来源:origin: eclipse-vertx/vert.x
private void writeBinaryFrameInternal(Buffer data) {
ByteBuf buf = data.getByteBuf();
WebSocketFrame frame = new WebSocketFrameImpl(FrameType.BINARY, buf);
writeFrame(frame);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public HttpServerResponse writeCustomFrame(int type, int flags, Buffer payload) {
synchronized (conn) {
checkEnded();
checkSendHeaders(false);
stream.writeFrame(type, flags, payload.getByteBuf());
ctx.flush();
return this;
}
}
代码示例来源:origin: eclipse-vertx/vert.x
public static Buffer leftPad(int padding, Buffer buffer) {
return Buffer.buffer(Unpooled.buffer()
.writerIndex(padding)
.readerIndex(padding)
.writeBytes(buffer.getByteBuf())
);
}
代码示例来源:origin: eclipse-vertx/vert.x
public Buffer setBuffer(int pos, Buffer b) {
ensureWritable(pos, b.length());
buffer.setBytes(pos, b.getByteBuf());
return this;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public HttpConnection goAway(long errorCode, int lastStreamId, Buffer debugData) {
if (errorCode < 0) {
throw new IllegalArgumentException();
}
if (lastStreamId < 0) {
lastStreamId = handler.connection().remote().lastStreamCreated();
}
handler.writeGoAway(errorCode, lastStreamId, debugData != null ? debugData.getByteBuf() : Unpooled.EMPTY_BUFFER);
return this;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testLength() throws Exception {
byte[] bytes = TestUtils.randomByteArray(100);
Buffer buffer = Buffer.buffer(bytes);
assertEquals(100, Buffer.buffer(buffer.getByteBuf()).length());
}
内容来源于网络,如有侵权,请联系作者删除!