Examples of ChannelBuffer


Examples of org.jboss.netty.buffer.ChannelBuffer

    _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

Examples of org.jboss.netty.buffer.ChannelBuffer

      // 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

Examples of org.jboss.netty.buffer.ChannelBuffer

      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

Examples of org.jboss.netty.buffer.ChannelBuffer

  /* (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

Examples of org.jboss.netty.buffer.ChannelBuffer

    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

Examples of org.jboss.netty.buffer.ChannelBuffer

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

Examples of org.jboss.netty.buffer.ChannelBuffer

    return null;
  }
 
  public String getStringMessage(MessageEvent e)
  {
    ChannelBuffer m = getMessage(e);
    if (m == null)
      return null;
    return m.toString(Charset.defaultCharset());
  }
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBuffer

              return Channels.pipeline(new SimpleChannelUpstreamHandler()
              {
            @Override
            public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception
            {
              ChannelBuffer b = mcast.getMessage(e);
              if (b == null)
                return;
              for (Channel c : remoteChannels)
              {
                if (c.isConnected())
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBuffer

  @Override
  void timedOut(ChannelHandlerContext ctx)
  {
      Constants.ahessianLogger.info("write timed out -> send empty buffer heartbeat");
    ChannelFuture future = Channels.future(_ctx.getChannel());
    ChannelBuffer b = ChannelBuffers.buffer(1);
    b.writeByte(0);
        _ctx.sendDownstream(new DownstreamMessageEvent(_ctx.getChannel(), future, b, _ctx.getChannel().getRemoteAddress()));
  }
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBuffer

                return Channels.pipeline(new SimpleChannelUpstreamHandler()
                {
            @Override
            public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception
            {
              ChannelBuffer b = mcast.getMessage(e);
              if (b == null)
                return;
              if (channel != null && channel.isConnected())
                channel.write(b);
            }
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.