class
XMPP::Carbons
- XMPP::Carbons
- Reference
- Object
Overview
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
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
Defined in:
xmpp/carbons.crConstant Summary
-
NS_CARBONS =
"urn:xmpp:carbons:2" -
Disco feature advertised by servers that support message carbons.
Constructors
Instance Method Summary
-
#disable(timeout : Time::Span = 5.seconds) : Stanza::IQ | Nil
disable turns off carbon copies for the client's resource.
-
#enable(timeout : Time::Span = 5.seconds) : Stanza::IQ | Nil
enable turns on carbon copies for the client's resource.
-
#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).
Constructor Detail
Instance Method Detail
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.