tcMenuJavaAPI
Public Member Functions | List of all members
com.thecoderscorner.menu.remote.socket.SocketControllerBuilder Class Reference
Inheritance diagram for com.thecoderscorner.menu.remote.socket.SocketControllerBuilder:
com.thecoderscorner.menu.remote.ConnectorFactory

Public Member Functions

SocketControllerBuilder withClock (Clock clock)
 
SocketControllerBuilder withExecutor (ScheduledExecutorService executor)
 
SocketControllerBuilder withMenuTree (MenuTree tree)
 
SocketControllerBuilder withProtocol (MenuCommandProtocol protocol)
 
SocketControllerBuilder withLocalName (String name)
 
SocketControllerBuilder withUUID (UUID uuid)
 
SocketControllerBuilder withAddress (String address)
 
SocketControllerBuilder withPort (int port)
 
RemoteMenuController build ()
 
boolean attemptPairing (Optional< Consumer< AuthStatus >> maybePairingListener)
 

Detailed Description

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();

Member Function Documentation

◆ attemptPairing()

boolean com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.attemptPairing ( Optional< Consumer< AuthStatus >>  maybePairingListener)

Attempt to pair with a remote optionally providing a listener that gets notified of status for updating a UI for example. It returns when pairing is complete.

Parameters
maybePairingListeneran optional pairing listener to listen for status updates
Returns
true if successful, otherwise false.
Exceptions
IOExceptionif the pairing connection fails.

Implements com.thecoderscorner.menu.remote.ConnectorFactory.

◆ build()

RemoteMenuController com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.build ( )

Once the above methods have been called to fill in the blanks, then call build to get the actual instance.

Returns
the actual instance.

Implements com.thecoderscorner.menu.remote.ConnectorFactory.

◆ withAddress()

SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withAddress ( String  address)

Mandatory, the address on which this socket is to bind to receive and send datagrams.

Parameters
addressaddress on which to send and receive.
Returns
itself, suitable for chaining.

◆ withClock()

SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withClock ( Clock  clock)

Optional, defaults to system clock but can be overriden

Parameters
clockthe clock to use
Returns
itself, can be chained

◆ withExecutor()

SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withExecutor ( ScheduledExecutorService  executor)

Optional, defaults to creating a suitable executor for single connectivity

Parameters
executorthe executor which must implement ScheduledExecutorService
Returns
itself, suitable for chaining.

◆ withLocalName()

SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withLocalName ( String  name)

Mandatory, Set the name of this connection

Parameters
namethe name the remote will see.
Returns
itself, suitable for chaining.

◆ withMenuTree()

SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.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
treethe menu tree to be populated (only use a menu tree with one remote)
Returns
itself, suitable for chaining.

◆ withPort()

SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withPort ( int  port)

Mandatory, the port locally on which to bind for multicast packets.

Parameters
portthe bind port
Returns
itself, suitable for chaining

◆ withProtocol()

SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withProtocol ( MenuCommandProtocol  protocol)

Optional, defaults to the standard protocol. Only use if changing the protocol which is not advised.

Parameters
protocola protocol object.
Returns
itself, suitable for chaining.

◆ withUUID()

SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withUUID ( UUID  uuid)

Mandatory, Set the UUID of this instance of the client

Parameters
uuidthe UUID for this instance of the App
Returns
itself, suitable for chaining.

The documentation for this class was generated from the following file: