Class LoginMessage


  • public class LoginMessage
    extends ObjectMessage
    The message sent when logging in.
    • 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 new LoginMessage with the supplied parameters.
        Parameters:
        player - The player 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 new LoginMessage from a stream.
        Parameters:
        ignoredGame - A Game (not actually used, the actual game is read from the stream).
        xr - The FreeColXMLReader 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()
      • 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 - The Game to look up.
        Returns:
        The ServerPlayer found.
      • clientHandler

        public void clientHandler​(FreeColClient freeColClient)
        Client-side handler for this message. Client handlers always return null.
        Overrides:
        clientHandler in class TrivialMessage
        Parameters:
        freeColClient - The FreeColClient to handle this message.
      • toXML

        public void toXML​(FreeColXMLWriter xw)
                   throws javax.xml.stream.XMLStreamException
        Write this message as XML.
        Overrides:
        toXML in class Message
        Parameters:
        xw - The FreeColXMLWriter to write with.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem writing the stream.
      • preGameLogin

        private ChangeSet preGameLogin​(FreeColServer freeColServer,
                                       Connection connection)
        Handle login to a completely new game.
        Parameters:
        freeColServer - The FreeColServer to log into.
        connection - The incoming Connection 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 - The FreeColServer to log into.
        connection - The incoming Connection 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 - The FreeColServer to log into.
        connection - The incoming Connection 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 incoming Connection.
        Returns:
        A ChangeSet encapsulating the login.