Package net.sf.freecol.common.networking
Class LoginMessage
- java.lang.Object
-
- net.sf.freecol.common.networking.Message
-
- net.sf.freecol.common.networking.TrivialMessage
-
- net.sf.freecol.common.networking.AttributeMessage
-
- net.sf.freecol.common.networking.ObjectMessage
-
- net.sf.freecol.common.networking.LoginMessage
-
public class LoginMessage extends ObjectMessage
The message sent when logging in.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.freecol.common.networking.Message
Message.MessagePriority
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCURRENT_PLAYER_TAGprivate PlayerplayerThe player in the attached game, if any.private static java.lang.StringSINGLE_PLAYER_TAGprivate static java.lang.StringSTATE_TAGstatic java.lang.StringTAGprivate static java.lang.StringUSER_NAME_TAGprivate static java.lang.StringVERSION_TAG-
Fields inherited from class net.sf.freecol.common.networking.AttributeMessage
attributes
-
Fields inherited from class net.sf.freecol.common.networking.TrivialMessage
continueMessage, disconnectMessage, endTurnMessage, enterRevengeModeMessage, reconnectMessage, requestLaunchMessage, retireMessage, startGameMessage
-
Fields inherited from class net.sf.freecol.common.networking.Message
logger, messagePriorityComparator
-
-
Constructor Summary
Constructors Constructor Description LoginMessage(Game ignoredGame, FreeColXMLReader xr)Create a newLoginMessagefrom a stream.LoginMessage(Player player, java.lang.String userName, java.lang.String version, FreeColServer.ServerState state, boolean singlePlayer, boolean currentPlayer, Game game)Create a newLoginMessagewith the supplied parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclientHandler(FreeColClient freeColClient)Client-side handler for this message.private booleangetCurrentPlayer()private GamegetGame()private PlayergetPlayer(Game game)Get the player (if any) with the current name in a given game.Message.MessagePrioritygetPriority()Get the priority of this type of message.private booleangetSinglePlayer()private FreeColServer.ServerStategetState()private java.lang.StringgetUserName()private java.lang.StringgetVersion()private ChangeSetinGameLogin(FreeColServer freeColServer, Connection connection)Handle login to a running game.private ChangeSetloadGameLogin(FreeColServer freeColServer, Connection connection)Handle login that loads an existing game.ChangeSetloginHandler(FreeColServer freeColServer, Connection connection)Special purpose handler for the UserConnectionHandler.private ChangeSetpreGameLogin(FreeColServer freeColServer, Connection connection)Handle login to a completely new game.voidtoXML(FreeColXMLWriter xw)Write this message as XML.-
Methods inherited from class net.sf.freecol.common.networking.ObjectMessage
appendChild, appendChildren, getChildCount, getChildren, setChildren
-
Methods inherited from class net.sf.freecol.common.networking.AttributeMessage
canMerge, getStringAttribute, getStringAttributeMap, hasAttribute, setMergeable, setStringAttribute
-
Methods inherited from class net.sf.freecol.common.networking.TrivialMessage
aiHandler, currentPlayerMessage, getType, serverHandler, setType
-
Methods inherited from class net.sf.freecol.common.networking.Message
clientGeneric, expected, getArrayAttributes, getBooleanAttribute, getChild, getChildren, getEnumAttribute, getIntegerAttribute, getPriorityLevel, igc, igc, invokeAndWait, invokeLater, isEmpty, isType, merge, pgc, pgc, pretty, read, setArrayAttributes, setArrayAttributes, setBooleanAttribute, setEnumAttribute, setIntegerAttribute, setStringAttributeMap, setStringAttributes, setStringAttributes, toString, writeAttributes, writeChildren
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
CURRENT_PLAYER_TAG
private static final java.lang.String CURRENT_PLAYER_TAG
- See Also:
- Constant Field Values
-
SINGLE_PLAYER_TAG
private static final java.lang.String SINGLE_PLAYER_TAG
- See Also:
- Constant Field Values
-
STATE_TAG
private static final java.lang.String STATE_TAG
- See Also:
- Constant Field Values
-
USER_NAME_TAG
private static final java.lang.String USER_NAME_TAG
- See Also:
- Constant Field Values
-
VERSION_TAG
private static final java.lang.String VERSION_TAG
- See Also:
- Constant Field Values
-
player
private Player player
The player in the attached game, if any.
-
-
Constructor Detail
-
LoginMessage
public LoginMessage(Player player, java.lang.String userName, java.lang.String version, FreeColServer.ServerState state, boolean singlePlayer, boolean currentPlayer, Game game)
Create a newLoginMessagewith the supplied parameters.- Parameters:
player- Theplayerto send to.userName- The name of the user logging in.version- The version of FreeCol at the client.state- The server state.singlePlayer- True in single player games.currentPlayer- True if this player is the current player.game- The entire game.
-
LoginMessage
public LoginMessage(Game ignoredGame, FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Create a newLoginMessagefrom a stream.- Parameters:
ignoredGame- AGame(not actually used, the actual game is read from the stream).xr- TheFreeColXMLReaderto read the message from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
-
Method Detail
-
getUserName
private java.lang.String getUserName()
-
getVersion
private java.lang.String getVersion()
-
getState
private FreeColServer.ServerState getState()
-
getSinglePlayer
private boolean getSinglePlayer()
-
getCurrentPlayer
private boolean getCurrentPlayer()
-
getGame
private Game getGame()
-
getPlayer
private Player getPlayer(Game game)
Get the player (if any) with the current name in a given game.- Parameters:
game- TheGameto look up.- Returns:
- The
ServerPlayerfound.
-
getPriority
public Message.MessagePriority getPriority()
Get the priority of this type of message.- Overrides:
getPriorityin classAttributeMessage- Returns:
- The message priority.
-
clientHandler
public void clientHandler(FreeColClient freeColClient)
Client-side handler for this message. Client handlers always return null.- Overrides:
clientHandlerin classTrivialMessage- Parameters:
freeColClient- TheFreeColClientto handle this message.
-
toXML
public void toXML(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write this message as XML.
-
preGameLogin
private ChangeSet preGameLogin(FreeColServer freeColServer, Connection connection)
Handle login to a completely new game.- Parameters:
freeColServer- TheFreeColServerto log into.connection- The incomingConnectionthat is logging in.- Returns:
- A
ChangeSetwith the result.
-
loadGameLogin
private ChangeSet loadGameLogin(FreeColServer freeColServer, Connection connection)
Handle login that loads an existing game.- Parameters:
freeColServer- TheFreeColServerto log into.connection- The incomingConnectionthat is logging in.- Returns:
- A
ChangeSetwith the result.
-
inGameLogin
private ChangeSet inGameLogin(FreeColServer freeColServer, Connection connection)
Handle login to a running game.- Parameters:
freeColServer- TheFreeColServerto log into.connection- The incomingConnectionthat is logging in.- Returns:
- A
ChangeSetwith the result.
-
loginHandler
public ChangeSet loginHandler(FreeColServer freeColServer, Connection connection)
Special purpose handler for the UserConnectionHandler.- Parameters:
freeColServer- The server to connect to.connection- The incomingConnection.- Returns:
- A
ChangeSetencapsulating the login.
-
-