edgeport - v1.0.6
    Preparing search index...

    Interface XmppSession

    A live XMPP session bound to one TCP/TLS connection.

    Obtain one from connect. A background pump routes inbound stanzas, so sending, receiving, and request-reply can all be in flight at once. It is an AsyncDisposable, so await using closes it cleanly (sending </stream:stream> first).

    1.0.4

    interface XmppSession {
        jid: string;
        "[asyncDispose]"(): PromiseLike<void>;
        addRosterItem(
            jid: string,
            opts?: { groups?: string[]; name?: string },
        ): Promise<void>;
        close(): Promise<void>;
        createNode(service: string, node: string): Promise<void>;
        iq(
            type: "set" | "get",
            child: XmlElement,
            opts?: { id?: string; timeoutMs?: number; to?: string },
        ): Promise<XmlElement>;
        messages(): AsyncIterable<XmppMessage>;
        presence(): AsyncIterable<XmppPresence>;
        publish(
            node: string,
            payload: string | XmlElement,
            opts?: { itemId?: string; service?: string },
        ): Promise<string>;
        pubsub(): AsyncIterable<PubSubEvent>;
        removeRosterItem(jid: string): Promise<void>;
        roster(): Promise<RosterItem[]>;
        send(opts: SendOptions): Promise<string>;
        sendStanza(
            stanza:
                | XmlElement
                | { attrs?: Record<string, string>; children?: XmlNode[]; name: string },
        ): Promise<void>;
        sendXML(xml: string): Promise<void>;
        setPresence(
            show: PresenceShow,
            opts?: { priority?: number; status?: string; to?: string },
        ): Promise<void>;
        subscribeNode(service: string, node: string): Promise<string | undefined>;
    }

    Hierarchy

    • AsyncDisposable
      • XmppSession
    Index
    jid: string

    The full bound JID (user@domain/resource).

    • Returns PromiseLike<void>

    • Adds or updates a roster item.

      Parameters

      • jid: string

        The contact's bare JID.

      • Optionalopts: { groups?: string[]; name?: string }

        Optional display name and groups.

      Returns Promise<void>

      Resolves once the server acknowledges.

      If the server returns an error.

    • Closes the stream (</stream:stream>) and the socket.

      Returns Promise<void>

      Resolves once the socket is closed.

    • Creates a pubsub node on a service (XEP-0060).

      Parameters

      • service: string

        The pubsub service (a component JID such as pubsub.example.com).

      • node: string

        The node id to create.

      Returns Promise<void>

      Resolves once the node is created.

      If creation fails (e.g. the node already exists).

    • Sends an <iq> request and waits for the correlated response.

      Parameters

      • type: "set" | "get"

        'get' or 'set'.

      • child: XmlElement

        The request payload element (e.g. a <query>).

      • Optionalopts: { id?: string; timeoutMs?: number; to?: string }

        Optional to, explicit id, and per-request timeoutMs.

      Returns Promise<XmlElement>

      The response <iq> element.

      If the response is an error, or the peer misbehaves.

      If no response arrives in time.

      If the session is closed.

    • Publishes an item to a pubsub node (PEP on your own account when no service is given).

      Parameters

      • node: string

        The node id.

      • payload: string | XmlElement

        The item payload: an XmlElement, a raw-XML string (parsed), or plain text (wrapped in a carrier element).

      • Optionalopts: { itemId?: string; service?: string }

        Optional service (publish to a pubsub component instead of PEP) and itemId.

      Returns Promise<string>

      The published item's id.

      If the server returns an error.

    • Removes a roster item.

      Parameters

      • jid: string

        The contact's bare JID.

      Returns Promise<void>

      Resolves once the server acknowledges.

      If the server returns an error.

    • Sends a chat message.

      Parameters

      • opts: SendOptions

        Recipient, body, and optional type/subject/thread/id.

      Returns Promise<string>

      The message id that was sent.

      If the session is closed.

    • Sends a raw stanza element (escape hatch).

      Parameters

      • stanza:
            | XmlElement
            | { attrs?: Record<string, string>; children?: XmlNode[]; name: string }

        An XmlElement, or a plain { name, attrs?, children? } object.

      Returns Promise<void>

      Resolves once written.

      If the session is closed.

    • Writes a raw XML string to the stream (escape hatch; not validated).

      Parameters

      • xml: string

        The XML to write verbatim.

      Returns Promise<void>

      Resolves once written.

      If the session is closed.

    • Broadcasts (or directs) a presence update.

      Parameters

      • show: PresenceShow

        The friendly presence state.

      • Optionalopts: { priority?: number; status?: string; to?: string }

        Optional free-text status, numeric priority, and directed to.

      Returns Promise<void>

      Resolves once the presence stanza is written.

      If the session is closed.

    • Subscribes to a pubsub node; events arrive via pubsub.

      Parameters

      • service: string

        The pubsub service (a component JID, or your bare JID for PEP).

      • node: string

        The node id.

      Returns Promise<string | undefined>

      The subscription id, when the server assigns one.

      If the server returns an error.