Package org.jboss.netty.buffer

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


                    this.fragmentOpcode = null;
                    frames.clear();
                }

                if (this.opcode == OPCODE_TEXT) {
                    if (frame.readableBytes() > MAX_LENGTH) {
                        throw new TooLongFrameException();
                    }
                    return new DefaultWebSocketFrame(0x00, frame);
                } else if (this.opcode == OPCODE_BINARY) {
                    return new DefaultWebSocketFrame(0xFF, frame);
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 == _receivedBytes.length)
View Full Code Here

          _currentToken = _tokens.get(new ByteArrayWrapper(_receivedBytes));
          if (_currentToken != null && (_uniqueLogon || _currentToken.isLoggedOn()))
          {
            logger.info("authenticated");
            ((SimpleAuthToken)_currentToken).setLoggedOn(true);
            if (b.readableBytes() != 0)
              ctx.sendUpstream(e);
            return PASSED;
          }
          else
          {
View Full Code Here

   * @see org.rzo.netty.ahessian.auth.AuthToken#authenticate(org.jboss.netty.channel.ChannelHandlerContext, org.jboss.netty.channel.MessageEvent)
   */
  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)
View Full Code Here

      if (_receivedLength == _password.length)
      {
        if (Arrays.equals(_receivedBytes, _password))
        {
          logger.info("authenticated");
          if (b.readableBytes() != 0)
            ctx.sendUpstream(e);
          return PASSED;
        }
        else
          return FAILED;
View Full Code Here

  public ChannelBuffer getMessage(MessageEvent e)
  {
    if (checkMessage(e))
    {
      ChannelBuffer m = (ChannelBuffer) e.getMessage();
      return m.slice(id.length, m.readableBytes()-id.length);
    }
    return null;
  }
 
  public String getStringMessage(MessageEvent e)
View Full Code Here

                            State state = (State) getAttribute(ctx, STATE_ATTRIBUTE);
                            int length = 0;
                            if (getAttributesMap(ctx).containsKey(LENGTH_ATTRIBUTE)) {
                                length = (Integer) getAttribute(ctx, LENGTH_ATTRIBUTE);
                            }
                            while (buffer.readableBytes() > 0) {
                                switch (state) {
                                case WAIT_FOR_FIRST_BYTE_LENGTH:
                                    length = (buffer.readByte() & 255) << 24;
                                    state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
                                    break;
View Full Code Here

                                    state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
                                    break;
                                case WAIT_FOR_FOURTH_BYTE_LENGTH:
                                    length += (buffer.readByte() & 255);
                                    state = State.READING;
                                    if ((length == 0) && (buffer.readableBytes() == 0)) {
                                        ctx.getChannel().write(ACK.slice());
                                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
                                    }
                                    break;
                                case READING:
View Full Code Here

                                        ctx.getChannel().write(ACK.slice());
                                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
                                    }
                                    break;
                                case READING:
                                    int remaining = buffer.readableBytes();
                                    if (length > remaining) {
                                        length -= remaining;
                                        buffer.skipBytes(remaining);
                                    } else {
                                        buffer.skipBytes(length);
View Full Code Here

                    @Override
                    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
                        if (e.getMessage() instanceof ChannelBuffer) {
                            ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
                            for (int i = 0; i < buffer.readableBytes(); ++i) {
                                counter.countDown();
                                if (counter.getCount() > 0) {
                                    sendMessage(ctx, data);
                                } else {
                                    ctx.getChannel().close();
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.