Class UDPBabelChannelBuilder

All Implemented Interfaces:
BabelChannelBuilder

public class UDPBabelChannelBuilder extends AbstractIPBabelChannelBuilder<UDPBabelChannelBuilder>
Builder / factory for UDPBabelChannel instances.

Configure the desired bind address and optional multicast parameters before building the channel:

BabelChannel channel = UDPBabelChannel.builder()
        .setBindingAddress(new InetSocketAddress("0.0.0.0", 7000))
        .build(babelRuntime, store, myself, protocol);

Once build(Babel, NodeStore, BabelNode, BabelProtocol) has been called, subsequent calls return the same UDPBabelChannel instance.

  • Constructor Details

    • UDPBabelChannelBuilder

      public UDPBabelChannelBuilder()
      Constructs a new UDPBabelChannelBuilder binding to the default port 7964.
  • Method Details

    • setNumberOfMulticastTtl

      public UDPBabelChannelBuilder setNumberOfMulticastTtl(int multicastTtl)
      Sets the Time-To-Live (TTL) hop count for outgoing multicast packets.
      Parameters:
      multicastTtl - the multicast TTL value
      Returns:
      this builder instance
      Throws:
      IllegalStateException - if the channel has already been built
    • addMulticastAddress

      public UDPBabelChannelBuilder addMulticastAddress(InetSocketAddress multicastAddress)
      Adds a multicast group address to join and broadcast to.
      Parameters:
      multicastAddress - the multicast socket address
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if the provided address is not a multicast address
      IllegalStateException - if the channel has already been built
    • build

      public BabelChannel build(Babel runtime, NodeStore store, BabelNode identity, BabelProtocol protocol)
      Description copied from interface: BabelChannelBuilder
      Creates a new BabelChannel instance, registering it with the given runtime and limiting its interest to the provided message types.
      Parameters:
      runtime - the owning Babel runtime
      store - the NodeStore that will be used by this channel
      identity - BabelNode object used to represent this Babel instance to other instances
      protocol - the protocol instance associated with this channel
      Returns:
      a ready-to-use BabelChannel