com.realtime.crossfire.jxclient.window
Class JXCConnection

java.lang.Object
  extended by com.realtime.crossfire.jxclient.window.JXCConnection

public class JXCConnection
extends java.lang.Object


Field Summary
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.
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  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 Summary
JXCConnection(KeybindingsManager keybindingsManager, Shortcuts shortcuts, Settings settings, java.awt.Frame frame, Pickup characterPickup, CrossfireServerConnection server, GuiStateManager guiStateManager)
          Creates a new instance.
 
Method Summary
private  void connect()
          Connect 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)
          Update the active character name.
 void setHost(java.lang.String serverInfo)
          Update information about the connected host.
private  void updateTitle()
          Update the window title to reflect the current connection state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

character

@Nullable
private java.lang.String character
The currently logged in character. Set to null if not logged in.


characterPickup

@NotNull
private final Pickup characterPickup
The Pickup instance to update.


crossfirePickupListener

@NotNull
private final CrossfirePickupListener crossfirePickupListener
The CrossfirePickupListener for tracking pickup mode changes.


DEFAULT_CROSSFIRE_PORT

private static final int DEFAULT_CROSSFIRE_PORT
The default port number for Crossfire servers.

See Also:
Constant Field Values

frame

@NotNull
private final java.awt.Frame frame
The Frame for updating the title.


guiStateListener

@NotNull
private final GuiStateListener guiStateListener
The GuiStateListener for detecting established or dropped connections.


hostname

@Nullable
private java.lang.String hostname
The currently connected server. Set to null if unconnected.


keybindingsManager

@NotNull
private final KeybindingsManager keybindingsManager
The KeybindingsManager to update.


port

private int port
The currently connected port. Only valid if hostname is set.


server

@NotNull
private final CrossfireServerConnection server
The CrossfireServerConnection instance used to connect to the Crossfire server.


settings

@NotNull
private final Settings settings
The settings instance to use.


shortcuts

@NotNull
private final Shortcuts shortcuts
The Shortcuts to update.


TITLE_PREFIX

@NotNull
private static final java.lang.String TITLE_PREFIX
The prefix for the window title.

See Also:
Constant Field Values
Constructor Detail

JXCConnection

public JXCConnection(@NotNull
                     KeybindingsManager keybindingsManager,
                     @NotNull
                     Shortcuts shortcuts,
                     @NotNull
                     Settings settings,
                     @NotNull
                     java.awt.Frame frame,
                     @NotNull
                     Pickup characterPickup,
                     @NotNull
                     CrossfireServerConnection server,
                     @NotNull
                     GuiStateManager guiStateManager)
Creates a new instance.

Parameters:
keybindingsManager - the keybindings manager to update
shortcuts - the shortcuts to update
settings - the settings instance to use
frame - the frame instance for updating the title
characterPickup - the character pickup instance to update
server - the crossfire server connection instance used to connect
guiStateManager - the gui state manager to watch
Method Detail

connect

private void connect()
Connect to the Crossfire server.


disconnect

private void disconnect(@NotNull
                        java.lang.String reason)
Disconnects from the Crossfire server.

Parameters:
reason - the reason for the disconnect

getHostname

@Nullable
public java.lang.String getHostname()
Returns the currently connected server.

Returns:
the server or null if unconnected

getPort

public int getPort()
Returns the currently connected port.

Returns:
the port or 0 if unconnected

setCharacter

public void setCharacter(@Nullable
                         java.lang.String character)
Update the active character name.

Parameters:
character - The active character; null if not logged in.

setHost

public void setHost(@Nullable
                    java.lang.String serverInfo)
Update information about the connected host.

Parameters:
serverInfo - The hostname; null if not connected.

updateTitle

private void updateTitle()
Update the window title to reflect the current connection state.