Class Ship

    • Constructor Detail

      • Ship

        public Ship​(java.lang.String alias,
                    ShipNodeConfiguration nodeConfig,
                    ConnectionHandler connHandler)
        constructor with parameters for convenience
        Parameters:
        alias - alias for the key pair in key store
        connHandler - connection handler
    • Method Detail

      • createTxtRecord

        public static TxtRecord createTxtRecord​(java.lang.String id,
                                                java.lang.String path,
                                                java.lang.String ski,
                                                boolean register)
      • createTxtRecord

        public static TxtRecord createTxtRecord​(java.lang.String id,
                                                java.lang.String path,
                                                java.lang.String ski,
                                                boolean register,
                                                java.lang.String brand,
                                                java.lang.String type,
                                                java.lang.String model)
      • createServiceInfo

        public static javax.jmdns.ServiceInfo createServiceInfo​(java.lang.String serviceName,
                                                                java.lang.String serviceInstance,
                                                                int port,
                                                                TxtRecord txt)
      • createServer

        public void createServer​(int port,
                                 java.lang.String wssPath,
                                 boolean keepAlive)
      • openConnection

        public ShipConnectionInterface openConnection​(java.lang.String ipAddr)
        opens a connection to a device/server
        Specified by:
        openConnection in interface ShipInterface
        Parameters:
        ipAddr - the IP address of the device/server to connect to. Example: "127.0.0.1:4059"
        Returns:
        an object representing the connection to the device/server if the connection was successful, else null
      • runConnectionDataPreparation

        public void runConnectionDataPreparation​(ShipConnection connection)
        run the states in connection data preparation, this method is non-blocking and the states will run asynchronously
        Parameters:
        connection - the connection that should run the connection data preparation states
      • getOwnSki

        public java.lang.String getOwnSki()
      • addTrustedSki

        public void addTrustedSki​(java.lang.String ski)
        adding a SKI authenticates the SHIP node using that SKI. The SKI of other SHIP nodes is typically communicated through the ConnectionHandler or manually acquired through ShipConnectionInterface
        Parameters:
        ski - the ski to add to the trusted SKIs
      • removeTrustedSki

        public boolean removeTrustedSki​(java.lang.String ski)
        tries to remove a ski from the trusted SKIs
        Parameters:
        ski - the ski to remove
        Returns:
        true if the ski was removed successfully, otherwise false, for example because the trusted SKI list did not contain the passed ski
      • setAutoAcceptMode

        public void setAutoAcceptMode()
        sets the node to auto-accept-mode. Authentication can be skipped that way but client has a time window for the connection, which can a preset value from 0 to 120 seconds. The default value for the window is 60 seconds. If the time window passed without any client connecting, the auto-accept-mode will be turned off.
      • getServices

        public javax.jmdns.ServiceInfo[] getServices()
        returns an array with all detected services, including own service
        Returns:
        the array with all detected services
      • shutDown

        public void shutDown()
                      throws java.io.IOException
        shuts down service discovery, all servers and clients on the node and the node itself
        Throws:
        java.io.IOException - if service discovery shutdown unsuccessful