Class UdpControllerBuilder


  • public class UdpControllerBuilder
    extends java.lang.Object
    Creates an instance of a RS232 based controller to a given port, and connects it with the selected menu. This implements the standard builder pattern, an example of use would be along the lines of: EXPERIMENTAL: DO NOT USE AT THE MOMENT
    • Constructor Detail

      • UdpControllerBuilder

        public UdpControllerBuilder()
    • Method Detail

      • withDeviceId

        public UdpControllerBuilder withDeviceId​(short deviceId)
        Mandatory, specifies the device ID to listen for.
        Parameters:
        deviceId - the identifier of the device we are connecting to
        Returns:
        itself, calls can be chained.
      • withSendFreq

        public UdpControllerBuilder withSendFreq​(long sendFreq)
        Optional, specifies the amount of time to wait before publishing a packet in millis, to try and send more than one at a time. ONLY CHANGE if you fully understand the parameter.
        Parameters:
        sendFreq - the send frequency
        Returns:
        itself, calls can be chained.
      • withClock

        public UdpControllerBuilder withClock​(java.time.Clock clock)
        Optional, defaults to system clock but can be overriden
        Parameters:
        clock - the clock to use
        Returns:
        itself, can be chained
      • withExecutor

        public UdpControllerBuilder withExecutor​(java.util.concurrent.ScheduledExecutorService executor)
        Optional, defaults to creating a suitable executor for single connectivity
        Parameters:
        executor - the executor which must implement ScheduledExecutorService
        Returns:
        itself, suitable for chaining.
      • withMenuTree

        public UdpControllerBuilder withMenuTree​(MenuTree tree)
        Mandatory, the menuTree instance to store the menu items retrieved from the remote side. this menuTree must only be used with one remote.
        Parameters:
        tree - the menu tree to be populated (only use a menu tree with one remote)
        Returns:
        itself, suitable for chaining.
      • withProtocol

        public UdpControllerBuilder withProtocol​(MenuCommandProtocol protocol)
        Optional, defaults to the standard protocol. Only use if changing the protocol which is not advised.
        Parameters:
        protocol - a protocol object.
        Returns:
        itself, suitable for chaining.
      • withSendAsDevice

        public UdpControllerBuilder withSendAsDevice​(boolean asDevice)
        Optional, normally set to false, as usually the Java API is not providing a menu as a device.
        Parameters:
        asDevice - false to act as a client, true if you want to act as a device.
        Returns:
        itself, suitable for chaining
      • withLocalName

        public UdpControllerBuilder withLocalName​(java.lang.String name)
        Optional, Set the name of this connection, defaults to NoName
        Parameters:
        name - the name the remote will see.
        Returns:
        itself, suitable for chaining.
      • withBindAddress

        public UdpControllerBuilder withBindAddress​(java.lang.String address)
        Mandatory, the address on which this socket is to bind to receive and send datagrams.
        Parameters:
        address - address on which to send and receive.
        Returns:
      • withPort

        public UdpControllerBuilder withPort​(int port)
        Mandatory, the port locally on which to bind for multicast packets.
        Parameters:
        port - the bind port
        Returns:
        itself, suitable for chaining
      • withUUID

        public UdpControllerBuilder withUUID​(java.util.UUID uuid)
        Mandatory, Set the UUID of this instance of the client
        Parameters:
        uuid - the UUID for this instance of the App
        Returns:
        itself, suitable for chaining.
      • build

        public RemoteMenuController build()
                                   throws java.io.IOException
        Once the above methods have been called to fill in the blanks, then call build to get the actual instance.
        Returns:
        the actual instance.
        Throws:
        java.io.IOException