Class TcpServer

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
org.drasyl.handler.remote.tcp.TcpServer
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

@UnstableApi public class TcpServer extends io.netty.channel.ChannelDuplexHandler
Starts a TCP-based server, allowing clients in very restrictive networks that do not allow UDP-based traffic to connect to this super peer via TCP.

This server is only used if the node act as a super peer.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Signals that the TcpServer was unable to bind to port.
    static class 
    Signals that the TcpServer is bind to TcpServer.TcpServerBound.getPort().

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Constructor Summary

    Constructors
    Constructor
    Description
    TcpServer(io.netty.channel.nio.NioEventLoopGroup group, InetAddress bindHost, int bindPort, Duration pingTimeout)
     
    TcpServer(io.netty.channel.nio.NioEventLoopGroup group, InetAddress bindHost, int bindPort, Duration pingTimeout, Function<io.netty.channel.ChannelHandlerContext,io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>> channelInitializerSupplier)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelActive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    channelInactive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)
     

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, close, connect, deregister, disconnect, flush, read

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Constructor Details

    • TcpServer

      public TcpServer(io.netty.channel.nio.NioEventLoopGroup group, InetAddress bindHost, int bindPort, Duration pingTimeout, Function<io.netty.channel.ChannelHandlerContext,io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>> channelInitializerSupplier)
      Parameters:
      group - the NioEventLoopGroup the underlying tcp server should run on
      channelInitializerSupplier -
    • TcpServer

      public TcpServer(io.netty.channel.nio.NioEventLoopGroup group, InetAddress bindHost, int bindPort, Duration pingTimeout)
      Parameters:
      group - the NioEventLoopGroup the underlying tcp server should run on
  • Method Details

    • write

      public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)
      Specified by:
      write in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      write in class io.netty.channel.ChannelDuplexHandler
    • channelActive

      public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws TcpServer.TcpServerBindFailedException
      Specified by:
      channelActive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      TcpServer.TcpServerBindFailedException
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter