Package com.thecoderscorner.menu.mgr
Class MenuManagerServer
java.lang.Object
com.thecoderscorner.menu.mgr.MenuManagerServer
- All Implemented Interfaces:
NewServerConnectionListener
The menu manager server component manages a menu tree locally, handling updates to both state and items, and also
dealing with any remote connections. To listen to updates you generally register a
MenuManagerListener that
will receive updates as items change. These listeners can also register themselves to handle list selection changes
and also to provide values for ScrollChoiceMenuItems.
In terms of remotes, many types of remote connections can be added, each type of remote is registered as a
ServerConnectionManager that handles one or more remote connection. This manager object provides much of the
functionality around managing connections, including joining, pairing, bootstrapping, handling the messages and
dealing with heartbeats.
Any authentication that is required is dealt with by an instance of MenuAuthenticator.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMenuManagerServer(ScheduledExecutorService executorService, MenuTree tree, String serverName, UUID uuid, MenuAuthenticator authenticator, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a connection manager to the list of connection managers.voidaddCustomMessageProcessor(MessageField msgType, BiConsumer<MenuManagerServer, MenuCommand> processor) Allows user level additional message processors for custom messages.voidaddMenuManagerListener(MenuManagerListener listener) Add a listener that will receive menu item events, such as when items change, and also when scroll choice values are needed.voidaddTreeStructureChangeListener(MenuTreeStructureChangeListener structureListener) Add a callback that will run when the tree has structurally changed.voidconnectionCreated(ServerConnection connection) Indicates that a connection has been created, implementing theNewServerConnectionListener.booleanIndicates if there is a remote connection on any of the server connection managersvoidmenuItemDidUpdate(Object sender, MenuItem item) Tell the manager that an update has already occurred, IE the menu tree state is already adjusted.voidsendCommand(MenuCommand command) Send a command to all remotes that are connected.voidsetDialogManager(DialogManager manager) replace the dialog manager with another implementation.voidstart()Start the manager and all associated server connection managersvoidstop()Stop the manager all associated resourcesvoidTell the manager that the tree has structurally changed and that any interested parties need notification.voidupdateMenuItem(Object sender, MenuItem item, Object newValue) Update the value for the given menu item.
-
Field Details
-
MSGTYPES_CANNOT_OVERRIDE
-
-
Constructor Details
-
Method Details
-
getDialogManager
- Returns:
- the dialog manager for this menu
-
start
public void start()Start the manager and all associated server connection managers -
stop
public void stop()Stop the manager all associated resources -
isAnyRemoteConnection
public boolean isAnyRemoteConnection()Indicates if there is a remote connection on any of the server connection managers- Returns:
- true if there is a connection, otherwise false
-
getAllServerConnections
- Returns:
- a list of all connections across all connection managers
-
getManagedMenu
- Returns:
- the menu tree belonging to this manager
-
getServerName
- Returns:
- the app name
-
getServerUuid
- Returns:
- UUID of the app, the local UUID
-
getAuthenticator
- Returns:
- the authenticator that is being used.