public class DefaultKeyHandler extends java.lang.Object implements KeyHandlerListener
KeyHandlerListener
which updates the state of a GuiManager
.Modifier and Type | Field and Description |
---|---|
private ClientSocketListener |
clientSocketListener
The
ClientSocketListener used to detect connection state
changes. |
private boolean |
connected
Whether a server connection is active.
|
private Exiter |
exiter
The
Exiter instance. |
private GuiManager |
guiManager
The
GuiManager instance. |
private GuiStateManager |
guiStateManager
The
GuiStateManager instance. |
private java.lang.Object |
semaphoreConnected
The synchronization object for accesses to
connected . |
Constructor and Description |
---|
DefaultKeyHandler(Exiter exiter,
GuiManager guiManager,
ServerConnection server,
GuiStateManager guiStateManager)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
escPressed()
The ESC key has been pressed.
|
private boolean |
isConnected()
Returns whether a server connection is active.
|
void |
keyReleased()
A key (but not ESC) has been released.
|
private void |
setConnected(boolean connected)
Records whether a server connection is active.
|
@NotNull private final ClientSocketListener clientSocketListener
ClientSocketListener
used to detect connection state
changes.private boolean connected
@NotNull private final GuiManager guiManager
GuiManager
instance.@NotNull private final GuiStateManager guiStateManager
GuiStateManager
instance.@NotNull private final java.lang.Object semaphoreConnected
connected
.public DefaultKeyHandler(@NotNull Exiter exiter, @NotNull GuiManager guiManager, @NotNull ServerConnection server, @NotNull GuiStateManager guiStateManager)
exiter
- the exiter instanceguiManager
- the gui manager instanceserver
- the server connection to trackguiStateManager
- the gui state manager instancepublic void escPressed()
escPressed
in interface KeyHandlerListener
private boolean isConnected()
public void keyReleased()
keyReleased
in interface KeyHandlerListener
private void setConnected(boolean connected)
connected
- whether a server connection is active