Handle incoming data during the handshake process. Should consume only the
handshake data from the buffer, leaving any extra data in place.

@param nextFilter the next filter
@param buf the server response data buffer
485309
public void messageReceived(final NextFilter nextFilter,
            final IoBuffer buf) {
        try {
            if (buf.remaining() >= SocksProxyConstants.SOCKS_4_RESPONSE_SIZE) {
                handleResponse(buf);
            }
        } catch (Exception ex) {
            closeSession("Proxy handshake failed: ", ex);
        }
    }
621951
public void applyFilter(int filter) {
        Filters.checkFilterArgument(filter);
        mDisplayRenderer.changeFilterMode(filter);
        synchronized (mReadyForFrameFence) {
            mNewFilter = filter;
        }
    }
1036044
void handleRequest(ByteBuf buffer) {
    long requestId = buffer.readLong();

    try {
      Object request = readRequest(buffer);
      HandlerHolder handler = handlers.get(request.getClass());
      if (handler != null) {
        handler.context.executor().execute(() -> handleRequest(requestId, request, handler));
      } else {
        handleRequestFailure(requestId, new SerializationException("unknown message type: " + request.getClass()), this.context);
      }
    } catch (SerializationException e) {
      handleRequestFailure(requestId, e, this.context);
    } finally {
      buffer.release();
    }
  }
421017
public void init(BaseMessageReceiver messageReceiver, BaseMessageFilter messageFilter)
    {
        if (messageFilter == null)
        {
            if (messageReceiver != null)
            {
                messageFilter = messageReceiver.createDefaultFilter(this);    // Add filter to handler
                return; // All done. (createDefaultFilter adds the message listener to the new filter)
            }
        }
        if (messageFilter != null)
            messageFilter.addMessageListener(this);     // This will also add the message filter to my list.
    }
523901
public void receive(byte[] buf, int off, int siz) throws IOException {
    int s = 0;

    while (s < siz) {
      int w = pgInput.read(buf, off + s, siz - s);
      if (w < 0) {
        throw new EOFException();
      }
      s += w;
    }
  }
1322630
@Override
  public NamingRegisterRequest decode(final byte[] buf) {
    final AvroNamingRegisterRequest avroNamingRegisterRequest =
        AvroUtils.fromBytes(buf, AvroNamingRegisterRequest.class);
    return new NamingRegisterRequest(
        new NameAssignmentTuple(factory.getNewInstance(avroNamingRegisterRequest.getId().toString()),
            new InetSocketAddress(avroNamingRegisterRequest.getHost().toString(), avroNamingRegisterRequest.getPort()))
    );
  }
769170
void sendNextProtocol(NextProtoNego.Provider provider) throws IOException
    {
        if (isInitialHandshake && provider != null)
        {
            if (protocols == null)
            {
                if (NextProtoNego.debug)
                    System.err.println(new StringBuilder("[C] NPN not received for ").append(conn != null ? conn : engine));
                ((NextProtoNego.ClientProvider)provider).unsupported();
            }
            else
            {
                try
                {
                    String protocol = ((NextProtoNego.ClientProvider)provider).selectProtocol(protocols);
                    if (NextProtoNego.debug)
                        System.err.println(new StringBuilder("[C] NPN selected '").append(protocol).append("' for ").append(conn != null ? conn : engine));
                    new NextProtocolMessage(protocol).write(output);
                    output.flush();
                }
                catch(Throwable t)
                {
                    fatalSE(Alerts.alert_handshake_failure, "NPN protocol selection failure", t);
                }
            }
        }
    }
608319
public static void storeBuffer(ByteBuf buf, Object message, RequestContext ctx) {
        IdentityHashMap<Object, ByteBuf> buffers = ctx.attr(BUFFERS).get();
        if (buffers == null) {
            buffers = new IdentityHashMap<>();
            ctx.attr(BUFFERS).set(buffers);
        }
        buffers.put(message, buf);
    }
614769
public void addMessageFilter(MessageFilter messageFilter)
    {
        super.addMessageFilter(messageFilter);
        try   {
            // If at all possible, pass the queue's current session, so the filter is in the proper environment
            if (((BaseMessageFilter)messageFilter).isCreateRemoteFilter())   // Almost always true
            {       // Create the remote version of this filter.
                RemoteSession remoteSession = (RemoteSession)((BaseMessageFilter)messageFilter).getRemoteSession();
                BaseMessageFilter remoteFilter = m_receiveQueue.addRemoteMessageFilter((BaseMessageFilter)messageFilter, remoteSession);
                ((BaseMessageFilter)messageFilter).setRemoteFilterInfo(remoteFilter.getQueueName(), remoteFilter.getQueueType(), remoteFilter.getFilterID(), remoteFilter.getRegistryID());
            }
        } catch (RemoteException ex)    {
            ex.printStackTrace();
        }
    }
790025
function(isGlobal, server, msg, session, cb) {
  var fm;
  if(isGlobal) {
    fm = server.globalFilterService;
  } else {
    fm = server.filterService;
  }
  if(fm) {
    fm.beforeFilter(msg, session, cb);
  } else {
    utils.invokeCallback(cb);
  }
}
391114
@Override
  @InService(PageServiceSync.class)
  public void afterDataFlush(PageServiceImpl tableService,
                             int sequenceFlush)
  {
    super.afterDataFlush(tableService, sequenceFlush);
    
    sweepStub(tableService);
  }
1278700
@Override
  public NamingLookupResponse decode(final byte[] buf) {
    final AvroNamingLookupResponse avroResponse = AvroUtils.fromBytes(buf, AvroNamingLookupResponse.class);
    final List<NameAssignment> nas = new ArrayList<>(avroResponse.getTuples().size());
    for (final AvroNamingAssignment tuple : avroResponse.getTuples()) {
      nas.add(
          new NameAssignmentTuple(
              factory.getNewInstance(tuple.getId().toString()),
              new InetSocketAddress(tuple.getHost().toString(), tuple.getPort())
          )
      );
    }
    return new NamingLookupResponse(nas);
  }
458373
private void handleRequest(final ChannelHandlerContext ctx, final ByteBuf message) {
    if (isDataMessage(message)) {
      dataEventHandler.onEvent(flowController, message);
    } else if (isControlMessage(message)) {
      controlHandler.onEvent(flowController, message);
    } else if (DcpNoopRequest.is(message)) {
      try {
        ByteBuf buffer = ctx.alloc().buffer();
        DcpNoopResponse.init(buffer);
        MessageUtil.setOpaque(MessageUtil.getOpaque(message), buffer);
        ctx.writeAndFlush(buffer);
      } finally {
        message.release();
      }
    } else {
      try {
        LOGGER.warn("Unknown DCP Message, ignoring. \n{}", MessageUtil.humanize(message));
      } finally {
        message.release();
      }
    }
  }
306802
public void onNext(DataMessage<T, DataBuffer> value) {
    DataBuffer buffer = value.getBuffer();
    if (buffer != null) {
      mBufferRepository.offerBuffer(buffer, value.getMessage());
    }
    mObserver.onNext(value.getMessage());
  }
797869
@SuppressWarnings("unchecked")
    @Override
    public final void filterClose(NextFilter nextFilter, IoSession session) throws Exception {
        doFilterClose(nextFilter, (T)session);
    }
693343
protected void onBlock(ConnectionFilter filter, String remoteAddr,
			int connections, int requests, int bytes) {
		filter.disconnect();
		filter.onDisconnect();
	}
29654
protected void handleRegularRequest(HttpServerExchange exchange, HttpObjectSocket httpObjectSocket, Object[] received, StreamSinkChannel sinkchannel) {
        ArrayList<IPromise> futures = new ArrayList<>();
        httpObjectSocket.getSink().receiveObject(received, futures, exchange.getRequestHeaders().getFirst("JWT") );

        Runnable reply = () -> {
            // piggy back outstanding lp messages, outstanding lp request is untouched
            Pair<byte[], Integer> nextQueuedMessage = httpObjectSocket.getNextQueuedMessage();
            byte response[] = nextQueuedMessage.getFirst();
            exchange.setResponseContentLength(response.length);
            if (response.length == 0) {
                exchange.endExchange();
            } else {
                httpObjectSocket.storeLPMessage(nextQueuedMessage.cdr(), response);

                //FIXME: ASYNC !!!
                long tim = System.nanoTime();
                ByteBuffer responseBuf = ByteBuffer.wrap(response);
                try {
                    while (responseBuf.remaining()>0) {
                        sinkchannel.write(responseBuf);
                    }
                } catch (IOException e) {
                    Log.Warn(this,e);
                }
//                System.out.println("syncwrite time micros:"+(System.nanoTime()-tim)/1000);
                exchange.endExchange();
            }
        };
        if ( futures == null || futures.size() == 0 ) {
            reply.run();
        } else {
            Actors.all((List) futures).timeoutIn(REQUEST_RESULTING_FUTURE_TIMEOUT).then( () -> {
                reply.run();
            }).onTimeout( () -> reply.run() );
            sinkchannel.resumeWrites();
        }
    }