Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer


            if (response.getStatus().getCode() == 200 && response.isChunked()) {
                readingChunks = true;
                System.out.println("CHUNKED CONTENT {");
            } else {
                ChannelBuffer content = response.getContent();
                if (content.readable()) {
                    System.out.println("CONTENT {");
                    System.out.println(content.toString(CharsetUtil.UTF_8));
                    System.out.println("} END OF CONTENT");
                }
            }
        } else {
            HttpChunk chunk = (HttpChunk) e.getMessage();
View Full Code Here


        }

        @Override
        public void messageReceived(ChannelHandlerContext ctx, final MessageEvent e)
                throws Exception {
            ChannelBuffer msg = (ChannelBuffer) e.getMessage();
            //System.out.println("<<< " + ChannelBuffers.hexDump(msg));
            synchronized (trafficLock) {
                inboundChannel.write(msg);
                // If inboundChannel is saturated, do not read until notified in
                // HexDumpProxyInboundHandler.channelInterestChanged().
View Full Code Here

    }

    @Override
    public void messageReceived(ChannelHandlerContext ctx, final MessageEvent e)
            throws Exception {
        ChannelBuffer msg = (ChannelBuffer) e.getMessage();
        //System.out.println(">>> " + ChannelBuffers.hexDump(msg));
        synchronized (trafficLock) {
            outboundChannel.write(msg);
            // If outboundChannel is saturated, do not read until notified in
            // OutboundHandler.channelInterestChanged().
View Full Code Here

  @Override
  protected Object encode(ChannelHandlerContext ctx, Channel channel, Object message) throws Exception
  {
    Message m = (Message) message;
    ChannelBuffer buffer = buffer(m.getMessage().length() + 2);
    buffer.writeByte(m.getCode());
    buffer.writeBytes(encoder.encode(CharBuffer.wrap(m.getMessage())));
    buffer.writeByte((byte) 0);
    // System.out.println("encode " + buffer.toString("UTF-8"));
    return buffer;
  }
View Full Code Here

public class MessageDecoder extends OneToOneDecoder
{
  @Override
  protected Object decode(ChannelHandlerContext ctx, Channel channel, Object message) throws Exception
  {
    ChannelBuffer b = (ChannelBuffer) message;

    byte code = b.readByte();
    // TODO remove the nul
    b.writerIndex(b.writerIndex());
    String msg = b.toString(Charset.defaultCharset().displayName());
    Message result = new Message(code, msg);
    return result;
  }
View Full Code Here

    _uniqueLogon = uniqueLogon;
  }

  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));
          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

      // if session established forward all messages
          if (_hasSession)
            ctx.sendUpstream(e);
          else
          {
            ChannelBuffer b = (ChannelBuffer) e.getMessage();
            _sessionId += b.toString("UTF-8");
            checkSession(ctx);
          }
            }
View Full Code Here

      session.onMessage();
      ctx.sendUpstream(e);
    }
    else
    {
      ChannelBuffer b = (ChannelBuffer) e.getMessage();
      _sessionId += b.toString("UTF-8");
      if (_sessionId.equals("?"))
        newSession(ctx);
      else
        checkSession(ctx);
    }
View Full Code Here

  /* (non-Javadoc)
   * @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)
      {
        if (Arrays.equals(_receivedBytes, _password))
        {
          logger.info("authenticated");
          if (b.readableBytes() != 0)
            ctx.sendUpstream(e);
          return PASSED;
        }
        else
          return FAILED;
View Full Code Here

    return init;
  }
 
  public void send(ChannelBuffer msg) throws Exception
  {
    ChannelBuffer idbuf = ChannelBuffers.wrappedBuffer(id);
    datagramChannel.write(ChannelBuffers.wrappedBuffer(idbuf, msg), multicastAddress);
  }
View Full Code Here

TOP

Related Classes of org.jboss.netty.buffer.ChannelBuffer

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.