Package io.vertx.core.parsetools

Examples of io.vertx.core.parsetools.RecordParser


  @Test
  public void testIllegalArguments() throws Exception {
    assertNullPointerException(() -> RecordParser.newDelimited((byte[]) null, handler -> {}));
    assertNullPointerException(() -> RecordParser.newDelimited((String) null, handler -> {}));

    RecordParser parser = RecordParser.newDelimited("", handler -> {});
    assertNullPointerException(() -> parser.setOutput(null));
    assertNullPointerException(() -> parser.delimitedMode((byte[]) null));
    assertNullPointerException(() -> parser.delimitedMode((String) null));
  }
View Full Code Here


      public void handle(Buffer buff) {
        results[pos++] = buff;
      }
    };
    RecordParser parser = RecordParser.newDelimited(delim, out);
    feedChunks(input, parser, chunkSizes);

    checkResults(expected, results);
  }
View Full Code Here

    }
  }

  private void setServerHandler(EventBusNetServer server) {
    Handler<NetSocket> sockHandler = socket -> {
      RecordParser parser = RecordParser.newFixed(4, null);
      Handler<Buffer> handler = new Handler<Buffer>() {
        int size = -1;
        public void handle(Buffer buff) {
          if (size == -1) {
            size = buff.getInt(0);
            parser.fixedSizeMode(size);
          } else {
            MessageImpl received = new MessageImpl();
            received.readFromWire(socket, buff, userCodecMap, systemCodecs);
            parser.fixedSizeMode(4);
            size = -1;
            if (received.codec() == PING_MESSAGE_CODEC) {
              // Just send back pong directly on connection
              if (sendPong) {
                socket.write(PONG);
              }
            } else {
              receiveMessage(received, -1, null, null);
            }
          }
        }
      };
      parser.setOutput(handler);
      socket.handler(parser);
    };
    server.setHandler(sockHandler);
  }
View Full Code Here

TOP

Related Classes of io.vertx.core.parsetools.RecordParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.