Class Jabber::XDelay
In: lib/xmpp4r/x/delay.rb
Parent: X
X XDelay XMuc XRoster XMucUser REXML::Element XRosterItem IqQuery XMLStanza IqVcard DiscoIdentity XMucUserItem DiscoItem Error RosterItem DiscoFeature IqQueryRoster IqQueryVersion IqQueryDiscoItems IqQueryDiscoInfo Message Presence Iq Singleton IdGenerator Connection Client Component Comparable JID RuntimeError ErrorException AuthenticationFailure RosterItem Stream StreamParser Roster Vcard Version lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/iq/query/roster.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/iq/query/version.rb lib/xmpp4r/connection.rb lib/xmpp4r/x/mucuseritem.rb lib/xmpp4r/x/roster.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/iq/query.rb lib/xmpp4r/xmlstanza.rb lib/xmpp4r/x/delay.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/client.rb lib/xmpp4r/stream.rb lib/xmpp4r/x/muc.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/x.rb lib/xmpp4r/iq/vcard.rb lib/xmpp4r/iq/query/discoinfo.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/message.rb lib/xmpp4r/iq/query/discoitems.rb lib/xmpp4r/presence.rb lib/xmpp4r/helpers/roster.rb lib/xmpp4r/helpers/vcard.rb lib/xmpp4r/helpers/version.rb Helpers Jabber Module: Jabber

Implementation of JEP 0091 for <x xmlns=’jabber:x:delay’ stamp=’…’ …/> applied on <message/> and <presence/> stanzas

One may also use XDelay#text for a descriptive reason for the delay.

Please note that you must require ‘xmpp4r/xdelay’ to use this class as it’s not required by a basic XMPP implementation. <x/> elements with the specific namespace will then be converted to XDelay automatically.

Methods

from   from=   new   set_from   set_stamp   stamp   stamp=  

Public Class methods

Initialize a new XDelay element

insertnow:[Boolean] Set the stamp to [Time::now]

[Source]

    # File lib/xmpp4r/x/delay.rb, line 27
27:     def initialize(insertnow=true)
28:       super()
29:       add_namespace('jabber:x:delay')
30: 
31:       if insertnow
32:         set_stamp(Time.now)
33:       end
34:     end

Public Instance methods

Get the timestamp’s origin

result:[JID]

[Source]

    # File lib/xmpp4r/x/delay.rb, line 74
74:     def from
75:       if attributes['from']
76:         JID::new(attributes['from'])
77:       else
78:         nil
79:       end
80:     end

Set the timestamp’s origin

jid:[JID]

[Source]

    # File lib/xmpp4r/x/delay.rb, line 85
85:     def from=(jid)
86:       attributes['from'] = jid.nil? ? nil : jid.to_s
87:     end

Set the timestamp’s origin (chaining-friendly)

[Source]

    # File lib/xmpp4r/x/delay.rb, line 91
91:     def set_from(jid)
92:       self.from = jid
93:       self
94:     end

Set the timestamp (chaining-friendly)

[Source]

    # File lib/xmpp4r/x/delay.rb, line 66
66:     def set_stamp(t)
67:       self.stamp = t
68:       self
69:     end

Get the timestamp

result:[Time] or nil

[Source]

    # File lib/xmpp4r/x/delay.rb, line 39
39:     def stamp
40:       if attributes['stamp']
41:         begin
42:           # Actually this should be Time.xmlschema,
43:           # but "unfortunately, the 'jabber:x:delay' namespace predates" JEP 0082
44:           Time.parse(attributes['stamp'])
45:         rescue ArgumentError
46:           nil
47:         end
48:       else
49:         nil
50:       end
51:     end

Set the timestamp

t:[Time] or nil

[Source]

    # File lib/xmpp4r/x/delay.rb, line 56
56:     def stamp=(t)
57:       if t.nil?
58:         attributes['stamp'] = nil
59:       else
60:         attributes['stamp'] = t.strftime("%Y%m%dT%H:%M:%S")
61:       end
62:     end

[Validate]