class

XMPP::Carbons

Inherits Reference / Object

Carbons is a high-level client for XEP-0280 - Message Carbons.

When enabled, the server carbon-copies the user's chat messages to all of the user's connected resources, wrapping each copy in a <sent/> or <received/> payload that forwards the original stanza. Enable the feature after the initial presence so the server knows the resource is online.

carbons = XMPP::Carbons.new(client) carbons.enable # after initial presence ... carbons.disable

Incoming carbon copies arrive as message extensions:

client.on("message") do |s, m| message = m.as(XMPP::Stanza::Message) if sent = message.get(XMPP::Stanza::CarbonSent) original = sent.forwarded.try(&.stanza) end end

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

Constants

NS_CARBONS = "urn:xmpp:carbons:2"

Disco feature advertised by servers that support message carbons.

Constructors

new(client : Client)
Source

Instance methods

disable(timeout : Time::Span = 5.seconds) : Stanza::IQ | Nil

disable turns off carbon copies for the client's resource. Returns the result/error IQ (nil on timeout).

Source
enable(timeout : Time::Span = 5.seconds) : Stanza::IQ | Nil

enable turns on carbon copies for the client's resource. Per XEP-0280 §3.2 this should be done after the initial presence. Returns the result/error IQ (nil on timeout).

Source
supported?(timeout : Time::Span = 5.seconds) : Bool

supported? queries the server for carbon support and returns true when the urn:xmpp:carbons:2 feature is advertised (XEP-0280 §3.1). The feature is advertised on the server domain rather than the user's bare JID.

Source