Package org.jboss.netty.buffer

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


  public int authenticate(ChannelHandlerContext ctx, MessageEvent e)
  {
        ChannelBuffer b = (ChannelBuffer) e.getMessage();
        int toCopy = Math.min(_receivedBytes.length-_receivedLength, b.readableBytes());
        byte[] bytes = new byte[toCopy];
        b.readBytes(bytes);
        System.arraycopy(bytes, 0, _receivedBytes, _receivedLength, bytes.length);
        _receivedLength += toCopy;
        if (_receivedLength == _receivedBytes.length)
        {
          _currentToken = _tokens.get(new ByteArrayWrapper(_receivedBytes));
View Full Code Here


  public int authenticate(ChannelHandlerContext ctx, MessageEvent e)
  {
      ChannelBuffer b = (ChannelBuffer) e.getMessage();
      int toCopy = Math.min(_receivedBytes.length-_receivedLength, b.readableBytes());
      byte[] bytes = new byte[toCopy];
      b.readBytes(bytes);
      System.arraycopy(bytes, 0, _receivedBytes, _receivedLength, bytes.length);
      _receivedLength += toCopy;
      if (_receivedLength == _password.length)
      {
        if (Arrays.equals(_receivedBytes, _password))
View Full Code Here

                if (outputStream == null) {
                    awaitingEvents.add(e);
                    return;
                }
                b = new byte[buffer.readableBytes()];
                buffer.readBytes(b);
                outputStream.write(b);
                outputStream.flush();
                success = true;
            } catch (Throwable t) {
                success = false;
View Full Code Here

            this.outputStream = outputStream;
            connected = true;
            for (MessageEvent awaitingEvent : awaitingEvents) {
                ChannelBuffer buffer = (ChannelBuffer) awaitingEvent.getMessage();
                byte[] b = new byte[buffer.readableBytes()];
                buffer.readBytes(b);
                try {
                    outputStream.write(b);
                    outputStream.flush();
                    awaitingEvent.getFuture().setSuccess();
                }
View Full Code Here

        response.setContentLength(length);
        response.setStatus(HttpServletResponse.SC_OK);
        for (MessageEvent event: buffers) {
            ChannelBuffer buffer = (ChannelBuffer) event.getMessage();
            byte[] b = new byte[buffer.readableBytes()];
            buffer.readBytes(b);
            try {
                response.getOutputStream().write(b);
                event.getFuture().setSuccess();
            } catch (IOException e) {
                event.getFuture().setFailure(e);
View Full Code Here

     * TODO: REST-Server value cannot be null ( null/empty string ?)
     */
    private void parseValue() {
        ChannelBuffer content = this.request.getContent();
        this.parsedValue = new byte[content.capacity()];
        content.readBytes(parsedValue);
    }
}
View Full Code Here

      HttpChunk msgReq = (HttpChunk)msgO;
      resp = msgReq.toString();
    } else {
      ChannelBuffer msg = (ChannelBuffer)msgO;
      byte[] bytes = new byte[msg.capacity()];
      msg.readBytes(bytes);
      msg.setIndex(0, bytes.length);
      StringBuilder out = new StringBuilder("MSG: ").append(e.getChannel().getRemoteAddress());
      out.append("\nMESSAGE length=").append(bytes.length).append("\n").append(new String(bytes));
      resp = out.toString();
    }
View Full Code Here

                    } else if(httpMethod.equals(HttpMethod.POST)) {
                        Map<String, Properties> configsToPut = Maps.newHashMap();
                        ChannelBuffer content = this.request.getContent();
                        if(content != null) {
                            byte[] postBody = new byte[content.capacity()];
                            content.readBytes(postBody);
                            configsToPut = ClientConfigUtil.readMultipleClientConfigAvro(new String(postBody));
                        }
                        response = handlePut(configsToPut);
                    } else if(httpMethod.equals(HttpMethod.DELETE)) {
                        if(storeList.size() == 0) {
View Full Code Here

      return msg;
    }
    ChannelBuffer buffer = (ChannelBuffer)msg;
    // buffer.array() will ignore the readerIndex. Hence readBytes is used
    // and then .array is called
    ByteArrayInputStream bis = new ByteArrayInputStream(buffer.readBytes(
        buffer.readableBytes()).array());
    return deSerializeObjectFromStream(bis);
  }

  @Override
View Full Code Here

        synchronized (z) {
            try {
                // Configure input.
                ChannelBuffer compressed = (ChannelBuffer) msg;
                byte[] in = new byte[compressed.readableBytes()];
                compressed.readBytes(in);
                z.next_in = in;
                z.next_in_index = 0;
                z.avail_in = in.length;

                // Configure output.
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.