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) |
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();
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.
maybePairingListener | an optional pairing listener to listen for status updates |
IOException | if the pairing connection fails. |
Implements com.thecoderscorner.menu.remote.ConnectorFactory.
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.
Implements com.thecoderscorner.menu.remote.ConnectorFactory.
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.
address | address on which to send and receive. |
SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withClock | ( | Clock | clock | ) |
Optional, defaults to system clock but can be overriden
clock | the clock to use |
SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withExecutor | ( | ScheduledExecutorService | executor | ) |
Optional, defaults to creating a suitable executor for single connectivity
executor | the executor which must implement ScheduledExecutorService |
SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withLocalName | ( | String | name | ) |
Mandatory, Set the name of this connection
name | the name the remote will see. |
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.
tree | the menu tree to be populated (only use a menu tree with one remote) |
SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withPort | ( | int | port | ) |
Mandatory, the port locally on which to bind for multicast packets.
port | the bind port |
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.
protocol | a protocol object. |
SocketControllerBuilder com.thecoderscorner.menu.remote.socket.SocketControllerBuilder.withUUID | ( | UUID | uuid | ) |
Mandatory, Set the UUID of this instance of the client
uuid | the UUID for this instance of the App |