Class Jabber::Message
In: lib/xmpp4r/message.rb
Parent: XMLStanza
XMLStanza Message Presence Iq REXML::Element X IqQuery Error StreamHost IqSiFileRange IqSiFile StreamHostUsed IqSi XRosterItem RosterItem IqFeature XMUCUserItem XMUCUserInvite XDataField XDataReported XDataTitle XDataInstructions Feature Identity Item IqVcard Singleton IdGenerator Connection Client Component Comparable JID RuntimeError AuthenticationFailure ErrorException SOCKS5Error Stream SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IBB IBBTarget IBBInitiator IqQuery IqQueryBytestreams IqQueryVersion IqQueryRoster IqQueryDiscoItems IqQueryDiscoInfo Responder SimpleResponder X XRoster XMUCUser XMUC XDelay XData MUCClient SimpleMUCClient Base DigestMD5 Plain FileSource StreamParser SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Helper MUCBrowser Helper Helper lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/connection.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/xmlstanza.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/stream.rb lib/xmpp4r/client.rb lib/xmpp4r/x.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/query.rb lib/xmpp4r/message.rb lib/xmpp4r/presence.rb lib/xmpp4r/bytestreams/helper/ibb/initiator.rb lib/xmpp4r/bytestreams/iq/si.rb lib/xmpp4r/bytestreams/iq/bytestreams.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb lib/xmpp4r/bytestreams/helper/ibb/base.rb lib/xmpp4r/bytestreams/helper/ibb/target.rb Bytestreams lib/xmpp4r/version/iq/version.rb lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb Version lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb lib/xmpp4r/roster/x/roster.rb Roster lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/muc/x/muc.rb lib/xmpp4r/muc/helper/mucclient.rb lib/xmpp4r/muc/x/mucuseritem.rb lib/xmpp4r/muc/helper/mucbrowser.rb lib/xmpp4r/muc/x/mucuserinvite.rb lib/xmpp4r/muc/helper/simplemucclient.rb MUC lib/xmpp4r/sasl.rb SASL lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber dot/m_60_0.png

The Message class manages the <message/> stanzas, which is used for all messaging communication.

Methods

body   body=   import   new   set_body   set_subject   set_thread   set_type   subject   subject=   thread   thread=   type   type=   typed_add   x  

Public Class methods

Create a new message from a stanza, by copying all attributes and children from it.

xmlstanza:[REXML::Element] Source
return:[Message] Result

[Source]

     # File lib/xmpp4r/message.rb, line 102
102:     def Message.import(xmlstanza)
103:       Message::new.import(xmlstanza)
104:     end

Create a new message

>to:a JID or a String object to send the message to.
>body:the message‘s body

[Source]

    # File lib/xmpp4r/message.rb, line 18
18:     def initialize(to = nil, body = nil)
19:       super("message")
20:       if not to.nil?
21:         set_to(to)
22:       end
23:       if !body.nil?
24:         add_element(REXML::Element::new("body").add_text(body))
25:       end
26:     end

Public Instance methods

Returns the message‘s body, or nil. This is the message‘s plain-text content.

[Source]

    # File lib/xmpp4r/message.rb, line 93
93:     def body
94:       first_element_text('body')
95:     end

Sets the message‘s body

b:[String] body to set

[Source]

     # File lib/xmpp4r/message.rb, line 110
110:     def body=(b)
111:       replace_element_text('body', b)
112:     end

Sets the message‘s body

b:[String] body to set
return:[REXML::Element] self for chaining

[Source]

     # File lib/xmpp4r/message.rb, line 119
119:     def set_body(b)
120:       self.body = b
121:       self
122:     end

sets the message‘s subject

s:[String] subject to set
return:[REXML::Element] self for chaining

[Source]

     # File lib/xmpp4r/message.rb, line 137
137:     def set_subject(s)
138:       self.subject = s
139:       self
140:     end

gets the message‘s thread (chaining-friendly) Please note that this are not [Thread] but a [String]-Identifier to track conversations

s:[String] thread to set

[Source]

     # File lib/xmpp4r/message.rb, line 160
160:     def set_thread(s)
161:       self.thread = s
162:       self
163:     end

Set the type of the Message stanza (chaining-friendly)

v:[Symbol] or nil

[Source]

    # File lib/xmpp4r/message.rb, line 79
79:     def set_type(v)
80:       self.type = v
81:       self
82:     end

Returns the message‘s subject, or nil

[Source]

     # File lib/xmpp4r/message.rb, line 144
144:     def subject
145:       first_element_text('subject')
146:     end

sets the message‘s subject

s:[String] subject to set

[Source]

     # File lib/xmpp4r/message.rb, line 128
128:     def subject=(s)
129:       replace_element_text('subject', s)
130:     end

Returns the message‘s thread, or nil

[Source]

     # File lib/xmpp4r/message.rb, line 167
167:     def thread
168:       first_element_text('thread')
169:     end

sets the message‘s thread

s:[String] thread to set

[Source]

     # File lib/xmpp4r/message.rb, line 151
151:     def thread=(s)
152:       delete_elements('thread')
153:       replace_element_text('thread', s) unless s.nil?
154:     end

Get the type of the Message stanza

The following Symbols are allowed:

  • :chat
  • :error
  • :groupchat
  • :headline
  • :normal
result:[Symbol] or nil

[Source]

    # File lib/xmpp4r/message.rb, line 51
51:     def type
52:       case super
53:         when 'chat' then :chat
54:         when 'error' then :error
55:         when 'groupchat' then :groupchat
56:         when 'headline' then :headline
57:         when 'normal' then :normal
58:         else nil
59:       end
60:     end

Set the type of the Message stanza (see Message#type for details)

v:[Symbol] or nil

[Source]

    # File lib/xmpp4r/message.rb, line 65
65:     def type=(v)
66:       case v
67:         when :chat then super('chat')
68:         when :error then super('error')
69:         when :groupchat then super('groupchat')
70:         when :headline then super('headline')
71:         when :normal then super('normal')
72:         else super(nil)
73:       end
74:     end

Add a sub-element

Will be converted to [X] if named "x"

element:[REXML::Element] to add

[Source]

    # File lib/xmpp4r/message.rb, line 33
33:     def typed_add(element)
34:       if element.kind_of?(REXML::Element) && (element.name == 'x')
35:         super(X::import(element))
36:       else
37:         super(element)
38:       end
39:     end

Get the first <x/> element of this stanza, or nil if none found.

[Source]

    # File lib/xmpp4r/message.rb, line 86
86:     def x
87:       first_element('x')
88:     end

[Validate]