Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer.array()


    // Note the index and go back to it when an incomplete message is received
    buf.markReaderIndex();

    // Read the record marking.
    ChannelBuffer fragmentHeader = buf.readBytes(4);
    int length = XDR.fragmentSize(fragmentHeader.array());
    boolean isLast = XDR.isLastFragment(fragmentHeader.array());

    // Make sure if there's enough bytes in the buffer.
    if (buf.readableBytes() < length) {
View Full Code Here


    buf.markReaderIndex();

    // Read the record marking.
    ChannelBuffer fragmentHeader = buf.readBytes(4);
    int length = XDR.fragmentSize(fragmentHeader.array());
    boolean isLast = XDR.isLastFragment(fragmentHeader.array());

    // Make sure if there's enough bytes in the buffer.
    if (buf.readableBytes() < length) {

      if (LOG.isTraceEnabled()) {
View Full Code Here

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
      // Get handle from create response
      ChannelBuffer buf = (ChannelBuffer) e.getMessage();
      XDR rsp = new XDR(buf.array());
      if (rsp.getBytes().length == 0) {
        LOG.info("rsp length is zero, why?");
        return;
      }
      LOG.info("rsp length=" + rsp.getBytes().length);
View Full Code Here

  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
    ChannelBuffer buf = (ChannelBuffer) e.getMessage();

    XDR request = new XDR();

    request.writeFixedOpaque(buf.array());
    InetAddress remoteInetAddr = ((InetSocketAddress) e.getRemoteAddress())
        .getAddress();
    XDR response = rpcProgram.handle(request, remoteInetAddr, null);
    e.getChannel().write(XDR.writeMessageUdp(response), e.getRemoteAddress());
  }
View Full Code Here

  }
 
  @Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
    ChannelBuffer buf = (ChannelBuffer) e.getMessage();
    XDR request = new XDR(buf.array());
   
    InetAddress remoteInetAddr = ((InetSocketAddress) ctx.getChannel()
        .getRemoteAddress()).getAddress();
    Channel outChannel = e.getChannel();
    XDR response = rpcProgram.handle(request, remoteInetAddr, outChannel);
View Full Code Here

    channelBuffer = (ChannelBuffer) decoder.decode(
        Mockito.mock(ChannelHandlerContext.class), Mockito.mock(Channel.class),
        buf);
    assertTrue(channelBuffer != null);
    // Complete frame should have to total size 10+10=20
    assertTrue(channelBuffer.array().length == 20);
  }

  @Test
  public void testFrames() {
View Full Code Here

       
            ChannelBuffer buf = (ChannelBuffer) e.getMessage();     
            byte[] line;
           
            if (buf.hasArray()) {
                line = buf.array();
            } else {
                // copy the ChannelBuffer to a byte array to process the LineHandler
                line = new byte[buf.capacity()];
                buf.getBytes(0, line);
            }
View Full Code Here

        Session pSession = (Session) attributes.get(ctx.getChannel());
       
        ChannelBuffer buf = (ChannelBuffer) e.getMessage();     
        byte[] line;
        if (buf.hasArray()) {
            line = buf.array();
        } else {
            // copy the ChannelBuffer to a byte array to process the LineHandler
            line = new byte[buf.capacity()];
            buf.getBytes(0, line);
        }
View Full Code Here

    {
      // inform client about amount of loaded bytes
      nettyNioClient.addToDownloadedBytes(numBytes);

      // process fetched data
      byte [] data = buf.array();
      handleResponse(e.getChannel(), data);
    }
  }
 
  @Override
View Full Code Here

       * pipeline); it fits single ddf message only w/o delimiters;
       */
      final ChannelBuffer frameBuffer = (ChannelBuffer) messageRAW;

      /* underlying frame array */
      byte[] array = frameBuffer.array();

      /*
       * silent ignore of invalid chunks sometimes sent by JERQ; DDF must
       * have at least 1 command char and 1 terminator
       */
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.