io.vertx.core.buffer.Buffer.getBuffer()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中io.vertx.core.buffer.Buffer.getBuffer()方法的一些代码示例,展示了Buffer.getBuffer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.getBuffer()方法的具体详情如下:
包路径:io.vertx.core.buffer.Buffer
类名称:Buffer
方法名:getBuffer

Buffer.getBuffer介绍

[英]Returns a copy of a sub-sequence the Buffer as a io.vertx.core.buffer.Buffer starting at position startand ending at position end - 1
[中]将子序列的副本作为io返回缓冲区。维特斯。果心缓冲器缓冲器起始位置和结束位置-1

代码示例

代码示例来源:origin: eclipse-vertx/vert.x

@Override
public Buffer decodeFromWire(int pos, Buffer buffer) {
 int length = buffer.getInt(pos);
 pos += 4;
 return buffer.getBuffer(pos, pos + length);
}

代码示例来源: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

demand--;
  Buffer event = buff.getBuffer(start, next);
  start = pos;
  Handler<Buffer> handler = eventHandler;
 buff = EMPTY_BUFFER;
} else {
 buff = buff.getBuffer(start, len);

代码示例来源:origin: eclipse-vertx/vert.x

private void feedChunks(Buffer input, RecordParser parser, Integer[] chunkSizes) {
 int pos = 0;
 int chunkPos = 0;
 while (pos < input.length()) {
  int chunkSize = chunkSizes[chunkPos++];
  if (chunkPos == chunkSizes.length) chunkPos = 0;
  int end = pos + chunkSize;
  end = end <= input.length() ? end : input.length();
  Buffer sub = input.getBuffer(pos, end);
  parser.handle(sub);
  pos += chunkSize;
 }
}

代码示例来源:origin: vert-x3/vertx-examples

final Buffer payload = buffer.getBuffer(1, buffer.length());
switch (type) {

代码示例来源:origin: eclipse-vertx/vert.x

if (arr.succeeded()) {
 for (int i = 0; i < chunks; i++) {
  Buffer chunk = buff.getBuffer(i * chunkSize, (i + 1) * chunkSize);
  assertEquals(chunkSize, chunk.length());
  arr.result().write(chunk, i * chunkSize, ar -> {

代码示例来源:origin: eclipse-vertx/vert.x

ws.exceptionHandler(t -> fail(t.getMessage()));
for (int i = 0; i < chunks; i++) {
 Buffer chunk = buff.getBuffer(i * chunkSize, (i + 1) * chunkSize);
 assertEquals(chunkSize, chunk.length());
 ws.write(chunk);

代码示例来源:origin: eclipse-vertx/vert.x

ws.exceptionHandler(t -> fail(t.getMessage()));
for (int i = 0; i < chunks; i++) {
 Buffer chunk = buff.getBuffer(i * chunkSize, (i + 1) * chunkSize);
 assertEquals(chunkSize, chunk.length());
 ws.write(chunk);

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testCopy() throws Exception {
 Buffer buff = TestUtils.randomBuffer(100);
 assertEquals(buff, buff.copy());
 Buffer copy = buff.getBuffer(0, buff.length());
 assertEquals(buff, copy);
 //Make sure they don't share underlying buffer
 Buffer copy2 = buff.copy();
 buff.setInt(0, 1);
 assertEquals(copy, copy2);
}

代码示例来源:origin: eclipse-vertx/vert.x

server.connectHandler(socket -> {
 socket.handler(buffer -> {
  if (!buffer.getBuffer(0, clientRequest.length()).equals(clientRequest)) {
   throw new IllegalStateException("expected " + toHex(clientRequest) + ", got " + toHex(buffer));
  String ip = getByte4(buffer.getBuffer(4, 8));
  String authUsername = getString(buffer.getBuffer(8, buffer.length()));
   String host;
   if (ip.equals("0.0.0.1")) {
    host = getString(buffer.getBuffer(9 + authUsername.length(), buffer.length()));
   } else {
    host = ip;

代码示例来源:origin: io.vertx/vertx-core

@Override
public Buffer decodeFromWire(int pos, Buffer buffer) {
 int length = buffer.getInt(pos);
 pos += 4;
 return buffer.getBuffer(pos, pos + length);
}

代码示例来源:origin: eclipse-vertx/vert.x

if (!buffer2.getBuffer(0, clientRequest.length()).equals(clientRequest)) {
 throw new IllegalStateException("expected " + toHex(clientRequest) + ", got " + toHex(buffer2));

代码示例来源:origin: io.vertx/vertx-core

@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: io.vertx/vertx-core

demand--;
  Buffer event = buff.getBuffer(start, next);
  start = pos;
  Handler<Buffer> handler = eventHandler;
 buff = EMPTY_BUFFER;
} else {
 buff = buff.getBuffer(start, len);

代码示例来源:origin: io.vertx/vertx-core

private void feedChunks(Buffer input, RecordParser parser, Integer[] chunkSizes) {
 int pos = 0;
 int chunkPos = 0;
 while (pos < input.length()) {
  int chunkSize = chunkSizes[chunkPos++];
  if (chunkPos == chunkSizes.length) chunkPos = 0;
  int end = pos + chunkSize;
  end = end <= input.length() ? end : input.length();
  Buffer sub = input.getBuffer(pos, end);
  parser.handle(sub);
  pos += chunkSize;
 }
}

代码示例来源:origin: io.vertx/vertx-core

if (arr.succeeded()) {
 for (int i = 0; i < chunks; i++) {
  Buffer chunk = buff.getBuffer(i * chunkSize, (i + 1) * chunkSize);
  assertEquals(chunkSize, chunk.length());
  arr.result().write(chunk, i * chunkSize, ar -> {

代码示例来源:origin: io.vertx/vertx-core

ws.exceptionHandler(t -> fail(t.getMessage()));
for (int i = 0; i < chunks; i++) {
 Buffer chunk = buff.getBuffer(i * chunkSize, (i + 1) * chunkSize);
 assertEquals(chunkSize, chunk.length());
 ws.write(chunk);

代码示例来源:origin: io.vertx/vertx-core

ws.exceptionHandler(t -> fail(t.getMessage()));
for (int i = 0; i < chunks; i++) {
 Buffer chunk = buff.getBuffer(i * chunkSize, (i + 1) * chunkSize);
 assertEquals(chunkSize, chunk.length());
 ws.write(chunk);

代码示例来源:origin: io.vertx/vertx-core

@Test
public void testCopy() throws Exception {
 Buffer buff = TestUtils.randomBuffer(100);
 assertEquals(buff, buff.copy());
 Buffer copy = buff.getBuffer(0, buff.length());
 assertEquals(buff, copy);
 //Make sure they don't share underlying buffer
 Buffer copy2 = buff.copy();
 buff.setInt(0, 1);
 assertEquals(copy, copy2);
}

代码示例来源:origin: io.vertx/vertx-core

server.connectHandler(socket -> {
 socket.handler(buffer -> {
  if (!buffer.getBuffer(0, clientRequest.length()).equals(clientRequest)) {
   throw new IllegalStateException("expected " + toHex(clientRequest) + ", got " + toHex(buffer));
  String ip = getByte4(buffer.getBuffer(4, 8));
  String authUsername = getString(buffer.getBuffer(8, buffer.length()));
   String host;
   if (ip.equals("0.0.0.1")) {
    host = getString(buffer.getBuffer(9 + authUsername.length(), buffer.length()));
   } else {
    host = ip;

相关文章