Class SocketControllerBuilder
java.lang.Object
com.thecoderscorner.menu.remote.socket.SocketControllerBuilder
- All Implemented Interfaces:
ConnectorFactory
Creates an instance of a socket 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:
RemoteMenuController controller = new SocketControllerBuilder()
.withAddress(hostName)
.withPort(3333)
.withMenuTree(myMenuTree)
.withLocalName("My App")
.withUUID(myUUID)
.build();
controller.start();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanattemptPairing(Optional<Consumer<AuthStatus>> maybePairingListener) build()Once the above methods have been called to fill in the blanks, then call build to get the actual instance.withAddress(String address) Mandatory, the address on which this socket is to bind to receive and send datagrams.Optional, defaults to system clock but can be overridenwithExecutor(ScheduledExecutorService executor) Optional, defaults to creating a suitable executor for single connectivitywithLocalName(String name) Mandatory, Set the name of this connectionwithMenuTree(MenuTree tree) Mandatory, the menuTree instance to store the menu items retrieved from the remote side.withPort(int port) Mandatory, the port locally on which to bind for multicast packets.withProtocol(MenuCommandProtocol protocol) Optional, defaults to the standard protocol.Mandatory, Set the UUID of this instance of the client
-
Constructor Details
-
SocketControllerBuilder
public SocketControllerBuilder()
-
-
Method Details
-
withClock
Optional, defaults to system clock but can be overriden- Parameters:
clock- the clock to use- Returns:
- itself, can be chained
-
withExecutor
Optional, defaults to creating a suitable executor for single connectivity- Parameters:
executor- the executor which must implement ScheduledExecutorService- Returns:
- itself, suitable for chaining.
-
withLocalName
Mandatory, Set the name of this connection- Parameters:
name- the name the remote will see.- Returns:
- itself, suitable for chaining.
-
withUUID
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.
-
withAddress
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:
- itself, suitable for chaining.
-
withPort
Mandatory, the port locally on which to bind for multicast packets.- Parameters:
port- the bind port- Returns:
- itself, suitable for chaining
-
build
Once the above methods have been called to fill in the blanks, then call build to get the actual instance.- Specified by:
buildin interfaceConnectorFactory- Returns:
- the actual instance.
-
attemptPairing
- Specified by:
attemptPairingin interfaceConnectorFactory
-