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.String
CURRENT_PLAYER_TAG
private Player
player
The player in the attached game, if any.private static java.lang.String
SINGLE_PLAYER_TAG
private static java.lang.String
STATE_TAG
static java.lang.String
TAG
private static java.lang.String
USER_NAME_TAG
private static java.lang.String
VERSION_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 newLoginMessage
from a stream.LoginMessage(Player player, java.lang.String userName, java.lang.String version, FreeColServer.ServerState state, boolean singlePlayer, boolean currentPlayer, Game game)
Create a newLoginMessage
with the supplied parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clientHandler(FreeColClient freeColClient)
Client-side handler for this message.private boolean
getCurrentPlayer()
private Game
getGame()
private Player
getPlayer(Game game)
Get the player (if any) with the current name in a given game.Message.MessagePriority
getPriority()
Get the priority of this type of message.private boolean
getSinglePlayer()
private FreeColServer.ServerState
getState()
private java.lang.String
getUserName()
private java.lang.String
getVersion()
private ChangeSet
inGameLogin(FreeColServer freeColServer, Connection connection)
Handle login to a running game.private ChangeSet
loadGameLogin(FreeColServer freeColServer, Connection connection)
Handle login that loads an existing game.ChangeSet
loginHandler(FreeColServer freeColServer, Connection connection)
Special purpose handler for the UserConnectionHandler.private ChangeSet
preGameLogin(FreeColServer freeColServer, Connection connection)
Handle login to a completely new game.void
toXML(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 newLoginMessage
with the supplied parameters.- Parameters:
player
- Theplayer
to 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 newLoginMessage
from a stream.- Parameters:
ignoredGame
- AGame
(not actually used, the actual game is read from the stream).xr
- TheFreeColXMLReader
to 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
- TheGame
to look up.- Returns:
- The
ServerPlayer
found.
-
getPriority
public Message.MessagePriority getPriority()
Get the priority of this type of message.- Overrides:
getPriority
in classAttributeMessage
- Returns:
- The message priority.
-
clientHandler
public void clientHandler(FreeColClient freeColClient)
Client-side handler for this message. Client handlers always return null.- Overrides:
clientHandler
in classTrivialMessage
- Parameters:
freeColClient
- TheFreeColClient
to 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
- TheFreeColServer
to log into.connection
- The incomingConnection
that is logging in.- Returns:
- A
ChangeSet
with the result.
-
loadGameLogin
private ChangeSet loadGameLogin(FreeColServer freeColServer, Connection connection)
Handle login that loads an existing game.- Parameters:
freeColServer
- TheFreeColServer
to log into.connection
- The incomingConnection
that is logging in.- Returns:
- A
ChangeSet
with the result.
-
inGameLogin
private ChangeSet inGameLogin(FreeColServer freeColServer, Connection connection)
Handle login to a running game.- Parameters:
freeColServer
- TheFreeColServer
to log into.connection
- The incomingConnection
that is logging in.- Returns:
- A
ChangeSet
with 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
ChangeSet
encapsulating the login.
-
-