Class UdpServer

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

@UnstableApi public class UdpServer extends io.netty.channel.ChannelDuplexHandler
Binds to an udp port, sends outgoing messages via udp, and sends received udp packets to the Channel.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Signals that the UdpServer was unable to bind to given address.
    static class 

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

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

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    UdpServer(io.netty.bootstrap.Bootstrap bootstrap, io.netty.channel.EventLoopGroup group, InetSocketAddress bindAddress)
     
    UdpServer(io.netty.bootstrap.Bootstrap bootstrap, io.netty.channel.EventLoopGroup group, InetSocketAddress bindAddress, Function<io.netty.channel.ChannelHandlerContext,io.netty.channel.ChannelInitializer<io.netty.channel.socket.DatagramChannel>> channelInitializerSupplier)
     
    UdpServer(io.netty.channel.EventLoopGroup group, int bindPort)
    Create UDP server that will bind to host 0.0.0.0 and port bindPort.
    UdpServer(io.netty.channel.EventLoopGroup group, String bindHost, int bindPort)
     
    UdpServer(io.netty.channel.EventLoopGroup group, InetAddress bindHost, int bindPort)
     
    UdpServer(io.netty.channel.EventLoopGroup group, InetAddress bindHost, int bindPort, Function<io.netty.channel.ChannelHandlerContext,io.netty.channel.ChannelInitializer<io.netty.channel.socket.DatagramChannel>> channelInitializerSupplier)
     
    UdpServer(io.netty.channel.EventLoopGroup group, InetSocketAddress bindAddress)
     
    UdpServer(io.netty.channel.EventLoopGroup group, InetSocketAddress bindAddress, Function<io.netty.channel.ChannelHandlerContext,io.netty.channel.ChannelInitializer<io.netty.channel.socket.DatagramChannel>> channelInitializerSupplier)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelActive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    channelInactive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    flush(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    handlerAdded(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, 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, 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

    handlerRemoved
  • Field Details

    • IP_TOS

      public static final int IP_TOS
  • Constructor Details

    • UdpServer

      public UdpServer(io.netty.bootstrap.Bootstrap bootstrap, io.netty.channel.EventLoopGroup group, InetSocketAddress bindAddress, Function<io.netty.channel.ChannelHandlerContext,io.netty.channel.ChannelInitializer<io.netty.channel.socket.DatagramChannel>> channelInitializerSupplier)
    • UdpServer

      public UdpServer(io.netty.bootstrap.Bootstrap bootstrap, io.netty.channel.EventLoopGroup group, InetSocketAddress bindAddress)
    • UdpServer

      public UdpServer(io.netty.channel.EventLoopGroup group, InetSocketAddress bindAddress, Function<io.netty.channel.ChannelHandlerContext,io.netty.channel.ChannelInitializer<io.netty.channel.socket.DatagramChannel>> channelInitializerSupplier)
      Parameters:
      group - the EventLoopGroup the underlying udp server should run on
      bindAddress - the address the UDP server will bind to
    • UdpServer

      public UdpServer(io.netty.channel.EventLoopGroup group, InetSocketAddress bindAddress)
      Parameters:
      group - the EventLoopGroup the underlying udp server should run on
      bindAddress - the address the UDP server will bind to
    • UdpServer

      public UdpServer(io.netty.channel.EventLoopGroup group, InetAddress bindHost, int bindPort, Function<io.netty.channel.ChannelHandlerContext,io.netty.channel.ChannelInitializer<io.netty.channel.socket.DatagramChannel>> channelInitializerSupplier)
      Parameters:
      group - the EventLoopGroup the underlying udp server should run on
      bindHost - the host the UDP server will bind to
      bindPort - the port the UDP server will bind to
    • UdpServer

      public UdpServer(io.netty.channel.EventLoopGroup group, InetAddress bindHost, int bindPort)
      Parameters:
      group - the EventLoopGroup the underlying udp server should run on
      bindHost - the host the UDP server will bind to
      bindPort - the port the UDP server will bind to
    • UdpServer

      public UdpServer(io.netty.channel.EventLoopGroup group, String bindHost, int bindPort)
      Parameters:
      group - the EventLoopGroup the underlying udp server should run on
      bindHost - the host the UDP server will bind to
      bindPort - the port the UDP server will bind to
    • UdpServer

      public UdpServer(io.netty.channel.EventLoopGroup group, int bindPort)
      Create UDP server that will bind to host 0.0.0.0 and port bindPort.
      Parameters:
      group - the EventLoopGroup the underlying udp server should run on
      bindPort - the port the UDP server will bind to
  • Method Details

    • handlerAdded

      public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      handlerAdded in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerAdded in class io.netty.channel.ChannelHandlerAdapter
    • channelActive

      public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws UdpServer.UdpServerBindFailedException
      Specified by:
      channelActive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      UdpServer.UdpServerBindFailedException
    • 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
    • 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
    • flush

      public void flush(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      flush in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      flush in class io.netty.channel.ChannelDuplexHandler
      Throws:
      Exception