22 package com.realtime.crossfire.jxclient.guistate;
26 import org.jetbrains.annotations.NotNull;
27 import org.jetbrains.annotations.Nullable;
46 private final Object
sync =
new Object();
60 if (this.guiState == guiState) {
77 listener.metaserver();
82 throw new IllegalArgumentException(
"changeGUI() called in state CONNECTING");
91 throw new IllegalArgumentException(
"changeGUI() called in state CONNECT_FAILED");
102 synchronized (
sync) {
103 if (this.guiState == guiState) {
111 throw new IllegalArgumentException(
"changeGUI() called in state START");
114 throw new IllegalArgumentException(
"changeGUI() called in state METASERVER");
118 listener.preConnecting(param);
121 listener.connecting(param);
126 throw new IllegalArgumentException(
"changeGUI() called in state CONNECTED");
130 listener.connectFailed(param);
143 synchronized (
sync) {
153 guiStateListeners.
add(listener);
161 guiStateListeners.
remove(listener);
168 public void connect(@NotNull
final String serverInfo) {
185 listener.connecting(clientSocketState);
197 public void disconnecting(@NotNull
final String reason,
final boolean isError) {
198 synchronized (
sync) {
209 synchronized (
sync) {
Interface for listeners interested gui state changes.
Maintains the current GuiState.
void addGuiStateListener(@NotNull final GuiStateListener listener)
Adds a gui state listener.
final EventListenerList2< GuiStateListener > guiStateListeners
The connection state listeners to notify.
A list of event listeners.
void disconnected()
Called after the connection has been closed.
void changeGUI(@NotNull final GuiState guiState)
Sets a new GuiState.
GuiState getGuiState()
Returns the current GuiState.
void disconnect()
Disconnects from the Crossfire server.
void connect(@NotNull final String serverInfo)
Connects to a Crossfire server.
final Object sync
The synchronization object for accessing guiState.
CONNECTING
Display the screen while a server connection is established.
CONNECT_FAILED
Display a failed connection attempt.
void removeGuiStateListener(@NotNull final GuiStateListener listener)
Removes a gui state listener.
void disconnecting(@NotNull final String reason, final boolean isError)
Called when the connection is being teared down.
CONNECTED
Display the main playing screen.
void add(@NotNull final T listener)
Adds a listener.
GuiState guiState
The current GUI state.
void setClientSocketState(@NotNull final ClientSocketState clientSocketState)
Sets the new ClientSocketState.
Utility class for Swing related functions.
void changeGUI(@NotNull final GuiState guiState, @NotNull final String param)
Sets a new GuiState.
METASERVER
Display the server selection screen.
void remove(@NotNull final T listener)
Removes a listener.
Connection progress states of the Crossfire server connection.
static void invokeAndWait(@NotNull final Runnable runnable)
Calls SwingUtilities#invokeAndWait(Runnable) if not on the EDT or calls the Runnable directly if on t...
CONNECTED
Connection is fully established.