public class JXCConnection
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
character
The currently logged in character.
|
private Pickup |
characterPickup
The
Pickup instance to update. |
private CrossfirePickupListener |
crossfirePickupListener
The
CrossfirePickupListener for tracking pickup mode changes. |
private static int |
DEFAULT_CROSSFIRE_PORT
The default port number for Crossfire servers.
|
private java.awt.Frame |
frame
The
Frame for updating the title or null . |
private GuiStateListener |
guiStateListener
The
GuiStateListener for detecting established or dropped
connections. |
private java.lang.String |
hostname
The currently connected server.
|
private KeybindingsManager |
keybindingsManager
The
KeybindingsManager to update. |
private Logger |
logger
The
Logger that is notified about changed server names. |
private int |
port
The currently connected port.
|
private CrossfireServerConnection |
server
The
CrossfireServerConnection instance used to connect to the
Crossfire server. |
private Settings |
settings
The settings instance to use.
|
private Shortcuts |
shortcuts
The
Shortcuts to update. |
private static java.lang.String |
TITLE_PREFIX
The prefix for the window title.
|
Constructor and Description |
---|
JXCConnection(KeybindingsManager keybindingsManager,
Shortcuts shortcuts,
Settings settings,
Pickup characterPickup,
CrossfireServerConnection server,
GuiStateManager guiStateManager,
Logger logger)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
private void |
connect()
Connects to the Crossfire server.
|
private void |
disconnect(java.lang.String reason)
Disconnects from the Crossfire server.
|
java.lang.String |
getHostname()
Returns the currently connected server.
|
int |
getPort()
Returns the currently connected port.
|
void |
setCharacter(java.lang.String character)
Updates the active character name.
|
void |
setFrame(java.awt.Frame frame)
Sets the
Frame for updating the title. |
void |
setHost(java.lang.String serverInfo)
Updates information about the connected host.
|
private void |
updateTitle()
Updates the window title to reflect the current connection state.
|
@Nullable private java.lang.String character
null
if not logged in.@NotNull private final CrossfirePickupListener crossfirePickupListener
CrossfirePickupListener
for tracking pickup mode changes.private static final int DEFAULT_CROSSFIRE_PORT
@Nullable private java.awt.Frame frame
Frame
for updating the title or null
.@NotNull private final GuiStateListener guiStateListener
GuiStateListener
for detecting established or dropped
connections.@Nullable private java.lang.String hostname
null
if unconnected.@NotNull private final KeybindingsManager keybindingsManager
KeybindingsManager
to update.private int port
hostname
is set.@NotNull private final CrossfireServerConnection server
CrossfireServerConnection
instance used to connect to the
Crossfire server.@NotNull private final Settings settings
@NotNull private static final java.lang.String TITLE_PREFIX
public JXCConnection(@NotNull KeybindingsManager keybindingsManager, @NotNull Shortcuts shortcuts, @NotNull Settings settings, @NotNull Pickup characterPickup, @NotNull CrossfireServerConnection server, @NotNull GuiStateManager guiStateManager, @NotNull Logger logger)
keybindingsManager
- the keybindings manager to updateshortcuts
- the shortcuts to updatesettings
- the settings instance to usecharacterPickup
- the character pickup instance to updateserver
- the crossfire server connection instance used to connectguiStateManager
- the gui state manager to watchlogger
- the logger to notify about changed server namesprivate void connect()
private void disconnect(@NotNull java.lang.String reason)
reason
- the reason for the disconnect@Nullable public java.lang.String getHostname()
null
if unconnectedpublic int getPort()
0
if unconnectedpublic void setCharacter(@Nullable java.lang.String character)
character
- the active character; null
if not logged inpublic void setFrame(@Nullable java.awt.Frame frame)
Frame
for updating the title.frame
- the frame or null
public void setHost(@Nullable java.lang.String serverInfo)
serverInfo
- the hostname; null
if not connectedprivate void updateTitle()