Class AIServerAPI


  • public class AIServerAPI
    extends ServerAPI
    Implementation of the ServerAPI for an AI without neither attached GUI nor real connection to the server.
    • Field Detail

      • owner

        private AIPlayer owner
        The AI player that owns this wrapper.
    • Constructor Detail

      • AIServerAPI

        public AIServerAPI​(AIPlayer owner)
        Create the new AI wrapper for the server API.
        Parameters:
        owner - The AIPlayer attached to this API.
    • Method Detail

      • getConnection

        public Connection getConnection()
        Get the connection to communicate with the server.
        Specified by:
        getConnection in class ServerAPI
        Returns:
        The Connection to the server.
      • connect

        public Connection connect​(java.lang.String name,
                                  java.lang.String host,
                                  int port)
                           throws java.io.IOException
        Connects a client to host:port (or more).
        Specified by:
        connect in class ServerAPI
        Parameters:
        name - The name for the thread.
        host - The name of the machine running the FreeColServer.
        port - The port to use when connecting to the host.
        Returns:
        True if the connection succeeded.
        Throws:
        java.io.IOException - on connection failure.
      • disconnect

        public boolean disconnect()
        Disconnect from the server.
        Specified by:
        disconnect in class ServerAPI
        Returns:
        True if disconnected.
      • reconnect

        public Connection reconnect()
                             throws java.io.IOException
        Reconnect to the server.
        Specified by:
        reconnect in class ServerAPI
        Returns:
        The reestablished Connection.
        Throws:
        java.io.IOException - on failure to connect.