Package org.jboss.netty.buffer

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


  {
    Object msgObj = e.getMessage();
    if (msgObj instanceof ChannelBuffer)
    {
      ChannelBuffer msgBuffer = (ChannelBuffer)msgObj;
      _msg = new String(msgBuffer.array());
    }
    super.messageReceived(ctx, e);
  }

  public String getMsg()
View Full Code Here


            ctx.getChannel().write(frame).addListener(ChannelFutureListener.CLOSE);
        } else if (frame instanceof PingWebSocketFrame) {
            ctx.getChannel().write(new PongWebSocketFrame(frame.getBinaryData()));
        } else if (frame instanceof BinaryWebSocketFrame) {
            ChannelBuffer binaryData = frame.getBinaryData();
            webSocketProcessor.invokeWebSocketProtocol((WebSocket) ctx.getAttachment(), binaryData.array(), binaryData.arrayOffset(), binaryData.readableBytes());
        } else if (frame instanceof TextWebSocketFrame) {
            webSocketProcessor.invokeWebSocketProtocol((WebSocket) ctx.getAttachment(), ((TextWebSocketFrame) frame).getText());
        } else if (frame instanceof PongWebSocketFrame) {
            if (config.enablePong()) {
                ctx.getChannel().write(new PingWebSocketFrame(frame.getBinaryData()));
View Full Code Here

                    }
                });

        ChannelBuffer internalBuffer = request.getContent();
        if (!config.aggregateRequestBodyInMemory() && !method.equalsIgnoreCase("GET")) {
            return requestBuilder.body(internalBuffer.array()).build();
        } else {
            logger.trace("Unable to read in memory the request's bytes. Using stream");
            return requestBuilder.inputStream(new ChannelBufferInputStream(internalBuffer)).build();
        }
    }
View Full Code Here

                        new StreamWriter(ctx.getChannel(), isLast, ka);
                method = request.getMethod();
                ChannelBuffer internalBuffer = HttpChunk.class.cast(messageEvent.getMessage()).getContent();

                if (!aggregateBodyInMemory && internalBuffer.hasArray()) {
                    request.body(internalBuffer.array());
                } else {
                    logger.trace("Unable to read in memory the request's bytes. Using stream");
                    request.body(new ChannelBufferInputStream(internalBuffer));
                }
View Full Code Here

            ChannelBuffer payload = buf.readBytes(length);


            // Successfully decoded a frame.
            // Return a TaskMessage object
            ret.add(new TaskMessage(task, payload.array()));
        }

        if (ret.size() == 0) {
            return null;
        } else {
View Full Code Here

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {       
        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

       
            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

            buffers[sequenceNumber] = ChannelBuffers.copiedBuffer(
                    CHUNK_MAGIC_BYTES,
                    messageId,
                    sequenceNumberArry,
                    sequenceCountArr,
                    payload.array()
            );
        }
        return buffers;
    }
View Full Code Here

        // 4 bytes of current time.
        messageId.writeInt((int) System.currentTimeMillis());
        messageId.writeInt(id);

        return messageId.array();
    }

    private byte[] generateMessageId() {
        return generateMessageId(0);
    }
View Full Code Here

        public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
            channels.add(e.getChannel());
            ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
            try {
                handoffQueue.put(buffer.array()); // this holds up the Netty upstream I/O thread if
                                                  // there's no receiver at the other end of the handoff queue
            } catch (InterruptedException ie) {
                Thread.currentThread().interrupt();
            }
        }
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.