java.lang.Object
java.lang.Thread
it.polimi.ingsw.am13.client.view.tui.MenuInputReader
- All Implemented Interfaces:
Runnable
Class implementing the thread listening for command line inputs from the user, used for TUI view
Note that, being an object mediating between the server and the client, it has references to both the
Once started, it catches anything typed via command line after pressing enter. It parses the first word of the typed line, interprets it as the command and uses the current menu exposed be the view to try and execute the command, otherwise it throws an exception. If the typed command is present in the menu, that
NetworkHandler
and the ViewTUI
.Once started, it catches anything typed via command line after pressing enter. It parses the first word of the typed line, interprets it as the command and uses the current menu exposed be the view to try and execute the command, otherwise it throws an exception. If the typed command is present in the menu, that
MenuItem
is executed, passing the rest of the parameters
typed after the command key to it.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final NetworkHandler
Reference to the handler of the network, to send commands to the serverprivate final Scanner
Scanner used to listen to the input from stdinprivate final ViewTUI
Reference to the view of the client.Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionMenuInputReader
(ViewTUI view, NetworkHandler networkHandler) Builds a new listeners for the command line input from the user -
Method Summary
Modifier and TypeMethodDescriptionvoid
run()
Listen for command line inputs coming from the user, and execute themMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
scanner
Scanner used to listen to the input from stdin -
view
Reference to the view of the client. It should be used only to handle the input-parsing exceptions. -
networkHandler
Reference to the handler of the network, to send commands to the server
-
-
Constructor Details
-
MenuInputReader
Builds a new listeners for the command line input from the user- Parameters:
view
- Reference of the view of the clientnetworkHandler
- Reference of the handler of the network
-
-
Method Details