tcMenuJavaAPI
Classes | Public Member Functions | Static Public Attributes | List of all members
com.thecoderscorner.menu.mgr.MenuManagerServer Class Reference
Inheritance diagram for com.thecoderscorner.menu.mgr.MenuManagerServer:
com.thecoderscorner.menu.mgr.NewServerConnectionListener

Public Member Functions

 MenuManagerServer (ScheduledExecutorService executorService, MenuTree tree, String serverName, UUID uuid, MenuAuthenticator authenticator, Clock clock)
 
void setBoardSerialProvider (Supplier< Integer > provider)
 
void addCustomMessageProcessor (MessageField msgType, BiConsumer< MenuManagerServer, MenuCommand > processor)
 
void setDialogManager (DialogManager manager)
 
DialogManager getDialogManager ()
 
void addConnectionManager (ServerConnectionManager manager)
 
void addMenuManagerListener (MenuManagerListener listener)
 
void addTreeStructureChangeListener (MenuTreeStructureChangeListener structureListener)
 
void start ()
 
void stop ()
 
boolean isAnyRemoteConnection ()
 
List< ServerConnectiongetAllServerConnections ()
 
void connectionCreated (ServerConnection connection)
 
MenuTree getManagedMenu ()
 
void updateMenuItem (Object sender, MenuItem item, Object newValue)
 
void menuItemDidUpdate (Object sender, MenuItem item)
 
void treeStructurallyChanged (MenuItem hint)
 
String getServerName ()
 
UUID getServerUuid ()
 
void sendCommand (MenuCommand command)
 
MenuAuthenticator getAuthenticator ()
 

Static Public Attributes

static final Set< MessageFieldMSGTYPES_CANNOT_OVERRIDE
 

Detailed Description

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.

Member Function Documentation

◆ addConnectionManager()

void com.thecoderscorner.menu.mgr.MenuManagerServer.addConnectionManager ( ServerConnectionManager  manager)

Add a connection manager to the list of connection managers. This will be started during start and any connections that are created will be serviced by this manager

Parameters
managera new connection manager

◆ addCustomMessageProcessor()

void com.thecoderscorner.menu.mgr.MenuManagerServer.addCustomMessageProcessor ( MessageField  msgType,
BiConsumer< MenuManagerServer, MenuCommand processor 
)

Allows user level additional message processors for custom messages. Using this you can provide your own message type at the API protocol level, and then use this to apply the additional functionality to the manager. The provided consumer will be called each time this custom message is applied. Note that you cannot override the core security based message types, any attempt to do so results in an exception.

Parameters
msgTypethe message type for your custom message
processorthe processor to handle the message.

◆ addMenuManagerListener()

void com.thecoderscorner.menu.mgr.MenuManagerServer.addMenuManagerListener ( MenuManagerListener  listener)

Add a listener that will receive menu item events, such as when items change, and also when scroll choice values are needed. In addition to the menuHasChanged() method you can register additional methods marking them with the MenuCallback annotation, and for every scroll choice item, you should register a value retrieval method using ScrollChoiceValueRetriever

Parameters
listenerthe new listener
See also
ScrollChoiceValueRetriever
MenuCallback
MenuManagerListener

◆ addTreeStructureChangeListener()

void com.thecoderscorner.menu.mgr.MenuManagerServer.addTreeStructureChangeListener ( MenuTreeStructureChangeListener  structureListener)

Add a callback that will run when the tree has structurally changed. IE when items are added or removed from sub menus

Parameters
structureListenerthe listener

◆ connectionCreated()

void com.thecoderscorner.menu.mgr.MenuManagerServer.connectionCreated ( ServerConnection  connection)

Indicates that a connection has been created, implementing the NewServerConnectionListener. For this we register ourselves as the message handler and send initial commands

Parameters
connectionthe new connection

Implements com.thecoderscorner.menu.mgr.NewServerConnectionListener.

◆ getAllServerConnections()

List<ServerConnection> com.thecoderscorner.menu.mgr.MenuManagerServer.getAllServerConnections ( )
Returns
a list of all connections across all connection managers

◆ getAuthenticator()

MenuAuthenticator com.thecoderscorner.menu.mgr.MenuManagerServer.getAuthenticator ( )
Returns
the authenticator that is being used.

◆ getDialogManager()

DialogManager com.thecoderscorner.menu.mgr.MenuManagerServer.getDialogManager ( )
Returns
the dialog manager for this menu

◆ getManagedMenu()

MenuTree com.thecoderscorner.menu.mgr.MenuManagerServer.getManagedMenu ( )
Returns
the menu tree belonging to this manager

◆ getServerName()

String com.thecoderscorner.menu.mgr.MenuManagerServer.getServerName ( )
Returns
the app name

◆ getServerUuid()

UUID com.thecoderscorner.menu.mgr.MenuManagerServer.getServerUuid ( )
Returns
UUID of the app, the local UUID

◆ isAnyRemoteConnection()

boolean com.thecoderscorner.menu.mgr.MenuManagerServer.isAnyRemoteConnection ( )

Indicates if there is a remote connection on any of the server connection managers

Returns
true if there is a connection, otherwise false

◆ menuItemDidUpdate()

void com.thecoderscorner.menu.mgr.MenuManagerServer.menuItemDidUpdate ( Object  sender,
MenuItem  item 
)

Tell the manager that an update has already occurred, IE the menu tree state is already adjusted. This just notifies locally and remotely.

Parameters
itemthe item that has adjusted

◆ sendCommand()

void com.thecoderscorner.menu.mgr.MenuManagerServer.sendCommand ( MenuCommand  command)

Send a command to all remotes that are connected.

Parameters
commandthe command to send

◆ setBoardSerialProvider()

void com.thecoderscorner.menu.mgr.MenuManagerServer.setBoardSerialProvider ( Supplier< Integer >  provider)

Allows for customization of the board serial number as a Supplier of Long. This will be called whenever the serial number is needed, and should return the value promptly to avoid connectivity issues.

Parameters
providerthe function that returns the serial number when requested.

◆ setDialogManager()

void com.thecoderscorner.menu.mgr.MenuManagerServer.setDialogManager ( DialogManager  manager)

replace the dialog manager with another implementation. By default, this class starts with an empty dialog manager that can be replaced with a more suitable implementation

Parameters
managerthe replacement dialog manager

◆ start()

void com.thecoderscorner.menu.mgr.MenuManagerServer.start ( )

Start the manager and all associated server connection managers

◆ stop()

void com.thecoderscorner.menu.mgr.MenuManagerServer.stop ( )

Stop the manager all associated resources

◆ treeStructurallyChanged()

void com.thecoderscorner.menu.mgr.MenuManagerServer.treeStructurallyChanged ( MenuItem  hint)

Tell the manager that the tree has structurally changed and that any interested parties need notification.

Parameters
hinteither MenuTree.ROOT or another item in the tree

◆ updateMenuItem()

void com.thecoderscorner.menu.mgr.MenuManagerServer.updateMenuItem ( Object  sender,
MenuItem  item,
Object  newValue 
)

Update the value for the given menu item. This updates the state in the underlying tree and sends notifications locally and remote

Parameters
itemthe item that has changed
newValuethe new value

Member Data Documentation

◆ MSGTYPES_CANNOT_OVERRIDE

final Set<MessageField> com.thecoderscorner.menu.mgr.MenuManagerServer.MSGTYPES_CANNOT_OVERRIDE
static
Initial value:
= Set.of(
MenuCommandType.CHANGE_INT_FIELD, MenuCommandType.DIALOG_UPDATE, MenuCommandType.JOIN, MenuCommandType.HEARTBEAT,
MenuCommandType.PAIRING_REQUEST, MenuCommandType.BOOTSTRAP)

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