net.sf.freecol.client.control
Class ConnectController

java.lang.Object
  extended by net.sf.freecol.client.control.ConnectController

public final class ConnectController
extends java.lang.Object

The controller responsible for starting a server and connecting to it. PreGameInputHandler will be set as the input handler when a successful login has been completed,


Constructor Summary
ConnectController(FreeColClient freeColClient)
          Creates a new ConnectController.
 
Method Summary
 java.util.ArrayList<ServerInfo> getServerList()
          Gets a list of servers from the meta server.
 void joinMultiplayerGame(java.lang.String username, java.lang.String host, int port)
          Starts a new multiplayer game by connecting to the server.
 void loadGame()
          Opens a dialog where the user should specify the filename and loads the game.
 void loadGame(java.io.File file)
          Loads a game from the given file.
 boolean login(java.lang.String username, java.lang.String host, int port)
          Starts the client and connects to host:port.
 void logout(boolean notifyServer)
          Sends a logout message to the server.
 void quitGame(boolean bStopServer)
          Quits the current game.
 void quitGame(boolean bStopServer, boolean notifyServer)
          Quits the current game.
 void reconnect()
          Reconnects to the server.
 void startMultiplayerGame(boolean publicServer, java.lang.String username, int port, NationOptions nationOptions)
          Starts a multiplayer server and connects to it.
 void startSingleplayerGame(java.lang.String username, NationOptions nationOptions)
          Starts a new singleplayer game by connecting to the server.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectController

public ConnectController(FreeColClient freeColClient)
Creates a new ConnectController.

Parameters:
freeColClient - The main controller.
Method Detail

startMultiplayerGame

public void startMultiplayerGame(boolean publicServer,
                                 java.lang.String username,
                                 int port,
                                 NationOptions nationOptions)
Starts a multiplayer server and connects to it.

Parameters:
publicServer - Should this server be listed at the meta server.
username - The name to use when logging in.
port - The port in which the server should listen for new clients.
nationOptions - a NationOptions value

startSingleplayerGame

public void startSingleplayerGame(java.lang.String username,
                                  NationOptions nationOptions)
Starts a new singleplayer game by connecting to the server.

Parameters:
username - The name to use when logging in.
nationOptions - a NationOptions value

joinMultiplayerGame

public void joinMultiplayerGame(java.lang.String username,
                                java.lang.String host,
                                int port)
Starts a new multiplayer game by connecting to the server.

Parameters:
username - The name to use when logging in.
host - The name of the machine running the FreeColServer.
port - The port to use when connecting to the host.

login

public boolean login(java.lang.String username,
                     java.lang.String host,
                     int port)
Starts the client and connects to host:port.

Parameters:
username - The name to use when logging in. This should be a unique identifier.
host - The name of the machine running the FreeColServer.
port - The port to use when connecting to the host.
Returns:
a boolean value

reconnect

public void reconnect()
Reconnects to the server.


loadGame

public void loadGame()
Opens a dialog where the user should specify the filename and loads the game.


loadGame

public void loadGame(java.io.File file)
Loads a game from the given file.

Parameters:
file - The File.

logout

public void logout(boolean notifyServer)
Sends a logout message to the server.

Parameters:
notifyServer - Whether or not the server should be notified of the logout. For example: if the server kicked us out then we don't need to confirm with a logout message.

quitGame

public void quitGame(boolean bStopServer,
                     boolean notifyServer)
Quits the current game. If a server is running it will be stopped if bStopServer is true. If a server is running through this client and bStopServer is true then the clients connected to that server will be notified. If a local client is connected to a server then the server will be notified with a logout in case notifyServer is true.

Parameters:
bStopServer - Indicates whether or not a server that was started through this client should be stopped.
notifyServer - Whether or not the server should be notified of the logout. For example: if the server kicked us out then we don't need to confirm with a logout message.

quitGame

public void quitGame(boolean bStopServer)
Quits the current game. If a server is running it will be stopped if bStopServer is true. The server and perhaps the clients (if a server is running through this client and bStopServer is true) will be notified.

Parameters:
bStopServer - Indicates whether or not a server that was started through this client should be stopped.

getServerList

public java.util.ArrayList<ServerInfo> getServerList()
Gets a list of servers from the meta server.

Returns:
A list of ServerInfo objects.