XMPP::Carbons
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
Disco feature advertised by servers that support message carbons.
Constructors
Instance methods
disable turns off carbon copies for the client's resource. Returns the result/error IQ (nil on timeout).
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).
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.