class XMPP::PrivateXmlStorage

Overview

PrivateXmlStorage is a high-level client for XEP-0049 - Private XML Storage.

Private XML storage lets a client persist small amounts of arbitrary XML on the server, keyed by an element's namespace/local name. Stored data is exchanged as a generic Stanza::Node, so any payload can round-trip.

storage = XMPP::PrivateXmlStorage.new(client) storage.store("storage:bookmarks", "storage", "example")

stored = storage.retrieve("storage:bookmarks", "storage")

See: https://xmpp.org/extensions/xep-0049.html

Defined in:

xmpp/private_xml_storage.cr

Constant Summary

NS_PRIVATE = "jabber:iq:private"

Namespace of the private-storage query wrapper.

Constructors

Instance Method Summary

Constructor Detail

def self.new(client : Client) #

[View source]

Instance Method Detail

def retrieve(namespace : String, name : String, timeout : Time::Span = 5.seconds) : Stanza::Node | Nil #

retrieve returns the stored element matching the given namespace and local name as a generic Stanza::Node, or nil when unset (or on error or timeout). The get request carries an empty element so the server knows which data to return.


[View source]
def store(namespace : String, name : String, contents : String, timeout : Time::Span = 5.seconds) : Stanza::IQ | Nil #

store is a convenience overload that builds a simple element with the given namespace, local name, and text content.


[View source]
def store(node : Stanza::Node, timeout : Time::Span = 5.seconds) : Stanza::IQ | Nil #

store persists the given element on the server. Returns the result/error IQ (nil on timeout); callers check type == "result".


[View source]