Class AdHocCommandManager


  • public final class AdHocCommandManager
    extends org.jivesoftware.smack.Manager
    An AdHocCommandManager is responsible for keeping the list of available commands offered by a service and for processing commands requests. Pass in an XMPPConnection instance to getAddHocCommandsManager(XMPPConnection) in order to get an instance of this class.
    • Method Detail

      • getAddHocCommandsManager

        @Deprecated
        public static AdHocCommandManager getAddHocCommandsManager​(org.jivesoftware.smack.XMPPConnection connection)
        Deprecated.
        Returns the AdHocCommandManager related to the connection.
        Parameters:
        connection - the XMPP connection.
        Returns:
        the AdHocCommandManager associated with the connection.
      • getInstance

        public static AdHocCommandManager getInstance​(org.jivesoftware.smack.XMPPConnection connection)
        Returns the AdHocCommandManager related to the connection.
        Parameters:
        connection - the XMPP connection.
        Returns:
        the AdHocCommandManager associated with the connection.
      • registerCommand

        public void registerCommand​(java.lang.String node,
                                    java.lang.String name,
                                    java.lang.Class<? extends AdHocCommandHandler> clazz)
                             throws java.lang.NoSuchMethodException,
                                    java.lang.SecurityException
        Registers a new command with this command manager, which is related to a connection. The node is an unique identifier of that command for the connection related to this command manager. The name is the human readable name of the command. The class is the class of the command, which must extend AdHocCommandHandler and have a default constructor.
        Parameters:
        node - the unique identifier of the command.
        name - the human readable name of the command.
        clazz - the class of the command, which must extend AdHocCommandHandler.
        Throws:
        java.lang.SecurityException - if there was a security violation.
        java.lang.NoSuchMethodException - if no such method is declared.
      • registerCommand

        public void registerCommand​(java.lang.String node,
                                    java.lang.String name,
                                    AdHocCommandHandlerFactory factory)
        Registers a new command with this command manager, which is related to a connection. The node is an unique identifier of that command for the connection related to this command manager. The name is the human readable name of the command. The factory generates new instances of the command.
        Parameters:
        node - the unique identifier of the command.
        name - the human readable name of the command.
        factory - a factory to create new instances of the command.
      • unregisterCommand

        public boolean unregisterCommand​(java.lang.String node)
      • discoverCommands

        public DiscoverItems discoverCommands​(org.jxmpp.jid.Jid jid)
                                       throws org.jivesoftware.smack.XMPPException,
                                              org.jivesoftware.smack.SmackException,
                                              java.lang.InterruptedException
        Discover the commands of an specific JID. The jid is a full JID.
        Parameters:
        jid - the full JID to retrieve the commands for.
        Returns:
        the discovered items.
        Throws:
        org.jivesoftware.smack.XMPPException - if the operation failed for some reason.
        org.jivesoftware.smack.SmackException - if there was no response from the server.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • getRemoteCommand

        public AdHocCommand getRemoteCommand​(org.jxmpp.jid.Jid jid,
                                             java.lang.String node)
        Returns a command that represents an instance of a command in a remote host. It is used to execute remote commands. The concept is similar to RMI. Every invocation on this command is equivalent to an invocation in the remote command.
        Parameters:
        jid - the full JID of the host of the remote command
        node - the identifier of the command
        Returns:
        a local instance equivalent to the remote command.
      • setDefaultSessionTimeoutSecs

        public static void setDefaultSessionTimeoutSecs​(int seconds)
      • setSessionTimeoutSecs

        public void setSessionTimeoutSecs​(int seconds)