Strophe.js
    Preparing search index...

    Class default

    Private helper class for managing stanza handlers.

    A Handler encapsulates a user provided callback function to be executed when matching stanzas are received by the connection. Handlers can be either one-off or persistant depending on their return value. Returning true will cause a Handler to remain active, and returning false will remove the Handler.

    Users will not use Handler objects directly, but instead they will use Connection.addHandler and Connection.deleteHandler.

    Index
    • Create and initialize a new Handler.

      Parameters

      • handler: (stanza: Element) => boolean

        A function to be executed when the handler is run.

      • Optionalns: string

        The namespace to match.

      • Optionalname: string

        The element name to match.

      • Optionaltype: string | string[]

        The stanza type (or types if an array) to match.

      • Optionalid: string

        The element id attribute to match.

      • Optionalfrom: string

        The element from attribute to match.

      • Optionaloptions: HandlerOptions

        Handler options

      Returns default

    from: string
    handler: (stanza: Element) => boolean
    id: string
    name: string
    ns: string
    type: string | string[]
    user: boolean
    • Returns the XML namespace of an element. Resolved via Strophe.getNamespace, which reads the xmlns attribute and falls back to namespaceURI so matching works regardless of how the stanza's DOM was built (locally, via DOMParser, or via the component transport's createElementNS). If ignoreNamespaceFragment was passed in for this handler, then the URL fragment will be stripped.

      Parameters

      • elem: Element

        The XML element with the namespace.

      Returns string

      The namespace, with optionally the fragment stripped.

    • Tests if a stanza matches the Handler.

      Parameters

      • elem: Element

        The XML element to test.

      Returns boolean

      true if the stanza matches and false otherwise.

    • Tests if a stanza element (or any of its children) matches the namespace set for this Handler.

      Parameters

      • elem: Element

        The XML element to test.

      Returns boolean

      true if the stanza matches and false otherwise.

    • Run the callback on a matching stanza.

      Parameters

      • elem: Element

        The DOM element that triggered the Handler.

      Returns boolean

      A boolean indicating if the handler should remain active.

    • Get a String representation of the Handler object.

      Returns string