All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arangodb.shaded.vertx.core.net.impl.NetSocketInternal Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
/*
 * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
 * which is available at https://www.apache.org/licenses/LICENSE-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
 */

package com.arangodb.shaded.vertx.core.net.impl;

import com.arangodb.shaded.netty.channel.ChannelHandler;
import com.arangodb.shaded.netty.channel.ChannelHandlerContext;
import com.arangodb.shaded.vertx.core.AsyncResult;
import com.arangodb.shaded.vertx.core.Future;
import com.arangodb.shaded.vertx.core.Handler;
import com.arangodb.shaded.vertx.core.net.NetSocket;

/**
 * Extends to expose Netty interactions for reusing existing Netty codecs and benefit from the features
 * {@link com.arangodb.shaded.vertx.core.net.NetServer} and {@link com.arangodb.shaded.vertx.core.net.NetClient}:
 *
 * 
    *
  • Server sharing
  • *
  • SSL/TLS
  • *
  • SNI
  • *
  • SSL/TLS upgrade
  • *
  • Write batching during read operation
  • *
  • Client proxy support
  • *
* * @author Julien Viet */ public interface NetSocketInternal extends NetSocket { /** * Returns the {@link ChannelHandlerContext} of the last handler (named {@code handler}) of the pipeline that * delivers message to the application with the {@link #handler(Handler)} and {@link #messageHandler(Handler)}. *

* Handlers should be inserted in the pipeline using {@link com.arangodb.shaded.netty.channel.ChannelPipeline#addBefore(String, String, ChannelHandler)}: *

*

   *   ChannelPipeline pipeline = so.channelHandlerContext().pipeline();
   *   pipeline.addBefore("handler", "myhandler", new MyHandler());
   * 
* @return the channel handler context */ ChannelHandlerContext channelHandlerContext(); /** * Write a message in the channel pipeline. *

* When a read operation is in progress, the flush operation is delayed until the read operation completes. * * @param message the message to write, it should be handled by one of the channel pipeline handlers * @return a future completed with the result */ Future writeMessage(Object message); /** * Like {@link #writeMessage(Object)} but with an {@code handler} called when the message has been written * or failed to be written. */ NetSocketInternal writeMessage(Object message, Handler> handler); /** * Set a {@code handler} on this socket to process the messages produced by this socket. The message can be * {@link com.arangodb.shaded.netty.buffer.ByteBuf} or other messages produced by channel pipeline handlers. *

* The {@code} handler should take care of releasing pooled / direct messages. *

* The handler replaces any {@link #handler(Handler)} previously set. * * @param handler the handler to set * @return a reference to this, so the API can be used fluently */ NetSocketInternal messageHandler(Handler handler); /** * Set an handler to process pipeline user events. * * The handler should take care of releasing event, e.g calling {@code ReferenceCountUtil.release(evt)}. * * @param handler the handler to set * @return a reference to this, so the API can be used fluently */ NetSocketInternal eventHandler(Handler handler); }