Package reactor.io

Examples of reactor.io.Buffer$View


    combined.writeBytes(partTwo);
    return combined;
  }

  private void passToConnection(ByteBuf data) {
    Buffer b = new Buffer(data.nioBuffer());
    int start = b.position();
    netChannel.read(b);
    data.skipBytes(b.position() - start);
  }
View Full Code Here


    }

    @Override
    public Buffer apply(Message<byte[]> message) {
      byte[] bytes = this.encoder.encode(message);
      return new Buffer(ByteBuffer.wrap(bytes));
    }
View Full Code Here

  @Test
  public void decodeMultipleFramesFromSameBuffer() {
    String frame1 = "SEND\ndestination:test\n\nThe body of the message\0";
    String frame2 = "DISCONNECT\n\n\0";

    Buffer buffer = Buffer.wrap(frame1 + frame2);

    final List<Message<byte[]>> messages = new ArrayList<Message<byte[]>>();
    new Reactor11StompCodec().decoder(new Consumer<Message<byte[]>>() {
      @Override
      public void accept(Message<byte[]> message) {
View Full Code Here

  @Test
  public void decodeHeartbeat() {
    String frame = "\n";

    Buffer buffer = Buffer.wrap(frame);

    final List<Message<byte[]>> messages = new ArrayList<Message<byte[]>>();
    new Reactor11StompCodec().decoder(new Consumer<Message<byte[]>>() {
      @Override
      public void accept(Message<byte[]> message) {
View Full Code Here

    assertEquals("SEND\ncontent-length:12\n\nMessage body\0",
        new Reactor11StompCodec().encoder().apply(frame).asString());
  }

  private void assertIncompleteDecode(String partialFrame) {
    Buffer buffer = Buffer.wrap(partialFrame);
    assertNull(decode(buffer));
    assertEquals(0, buffer.position());
  }
View Full Code Here

    assertNull(decode(buffer));
    assertEquals(0, buffer.position());
  }

  private Message<byte[]> decode(String stompFrame) {
    Buffer buffer = Buffer.wrap(stompFrame);
    return decode(buffer);
  }
View Full Code Here

  @Override
  public Function<OUT, Buffer> encoder() {
    return new Function<OUT, Buffer>() {
      @Override
      public Buffer apply(OUT out) {
        Buffer buff = delegate.encoder().apply(out);
        try {
          ByteArrayOutputStream bout = new ByteArrayOutputStream();
          OutputStream zout = createOutputStream(bout);
          zout.write(buff.asBytes());
          zout.flush();
          bout.flush();
          zout.close();
          return Buffer.wrap(bout.toByteArray());
        } catch(IOException e) {
View Full Code Here

          buffer.limit(limit);
          buffer.position(pos);
          return null;
        }

        Buffer prefixBuff = new Buffer(prefixLength, true).append(prefix.get()).flip();
        Buffer dataBuff = new Buffer(data.getEnd() - data.getStart(), true).append(data.get()).flip();

        buffer.limit(limit);

        Frame f = new Frame(prefixBuff, dataBuff);
        if(null != next) {
View Full Code Here

  }

  @Test
  @Ignore
  public void clockByteBufferGetInt() {
    final Buffer b = Buffer.wrap("34");

    Consumer<Integer> test = new Consumer<Integer>() {
      @Override
      public void accept(Integer integer) {
        Buffer.parseInt(b);
View Full Code Here

  @Test
  @Ignore
  public void clockManualDateExtraction() {
    final String[] months = new String[]{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    final Buffer date = Buffer.wrap("Oct 11 22:14:15");
    final Iterable<Buffer.View> slices = date.slice(0, 3, 4, 6, 7, 9, 10, 12, 13);

    Consumer<Integer> test = new Consumer<Integer>() {
      Calendar cal = Calendar.getInstance();

      @Override
      public void accept(Integer integer) {
        Iterator<Buffer.View> iter = slices.iterator();

        Buffer b = iter.next().get();
        int month = Arrays.binarySearch(months, b.asString());
        int day = Buffer.parseInt(iter.next().get());
        int hr = Buffer.parseInt(iter.next().get());
        int min = Buffer.parseInt(iter.next().get());
        int sec = Buffer.parseInt(iter.next().get());
View Full Code Here

TOP

Related Classes of reactor.io.Buffer$View

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.