Class Jabber::Message
In: lib/xmpp4r/message.rb
Parent: XMPPStanza
Message Presence XMPPStanza Iq XMPPElement ErrorResponse X IqQuery JabberError ComponentAuthenticationFailure ArgumentError InvalidChatState SOCKS5Error ServerError NoNameXmlnsRegistered ServerDisconnected ClientAuthenticationFailure Connection Client Component Connection Client Singleton IdGenerator Comparable JID Enumerable CallbackList Items Publish StandardError REXML::Element Stream XMPPElement Location IqFeature StreamHost IqSiFile IqSiFileRange IqSi StreamHostUsed XRosterItem RosterItem C Body HTML UserItem XMUCUserInvite Configuration Retract IqPubSub Item IqPubSubOwner Event Subscription Unsubscribe Tune XDataField XDataReported XDataTitle XDataInstructions Feature Item Identity IqVcard PubSub::ServiceHelper Helper Helper SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IqQuery IqQueryBytestreams IqQueryRoster IqQueryVersion IqQueryRPC IqQueryMUCOwner IqQueryMUCAdmin IqQueryDiscoItems IqQueryDiscoInfo IqQueryLastActivity IBB IBBTarget IBBInitiator RosterXItem XRoster RosterX X XDelay XMUC XMUCUser XData Responder SimpleResponder Iq IqCommand XMLRPC::ParserWriterChooseMixin Client Server XMLRPC::ParseContentType XMLRPC::BasicServer MUCClient SimpleMUCClient MUC::UserItem XMUCUserItem IqQueryMUCAdminItem XParent SubscriptionConfig NodeConfig OwnerNodeConfig EventItems ServiceHelper OAuthServiceHelper NodeHelper EventItem Base Anonymous DigestMD5 Plain FileSource Base Bot Callback StreamParser Semaphore SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Helper Responder Helper Listener MUCBrowser NodeBrowser ListenerMocker Helper Responder Helper Helper Helper lib/xmpp4r/message.rb lib/xmpp4r/connection.rb lib/xmpp4r/xmppstanza.rb lib/xmpp4r/iq.rb lib/xmpp4r/callbacks.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/stream.rb lib/xmpp4r/client.rb lib/xmpp4r/jid.rb lib/xmpp4r/x.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/semaphore.rb lib/xmpp4r/errors.rb lib/xmpp4r/component.rb lib/xmpp4r/presence.rb lib/xmpp4r/xmppelement.rb lib/xmpp4r/query.rb XParent lib/xmpp4r/location/helper/helper.rb lib/xmpp4r/location/location.rb UserLocation lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/bytestreams/iq/si.rb lib/xmpp4r/bytestreams/helper/ibb/initiator.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb lib/xmpp4r/bytestreams/iq/bytestreams.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb lib/xmpp4r/bytestreams/helper/ibb/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb lib/xmpp4r/bytestreams/helper/ibb/base.rb Bytestreams lib/xmpp4r/roster/x/roster.rb lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb Roster lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb lib/xmpp4r/version/iq/version.rb Version lib/xmpp4r/command/iq/command.rb lib/xmpp4r/command/helper/responder.rb Command lib/xmpp4r/caps/helper/helper.rb lib/xmpp4r/caps/c.rb Caps lib/xmpp4r/reliable.rb Reliable lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/xhtml/html.rb XHTML lib/xmpp4r/rpc/helper/server.rb lib/xmpp4r/rpc/helper/client.rb lib/xmpp4r/rpc/iq/rpc.rb RPC lib/xmpp4r/muc/iq/mucadminitem.rb lib/xmpp4r/muc/x/muc.rb lib/xmpp4r/muc/item.rb lib/xmpp4r/muc/helper/simplemucclient.rb lib/xmpp4r/muc/iq/mucadmin.rb lib/xmpp4r/muc/helper/mucbrowser.rb lib/xmpp4r/muc/x/mucuseritem.rb lib/xmpp4r/muc/x/mucuserinvite.rb lib/xmpp4r/muc/iq/mucowner.rb lib/xmpp4r/muc/helper/mucclient.rb MUC lib/xmpp4r/pubsub/children/item.rb lib/xmpp4r/pubsub/children/configuration.rb lib/xmpp4r/pubsub/children/subscription.rb lib/xmpp4r/pubsub/helper/servicehelper.rb lib/xmpp4r/pubsub/children/unsubscribe.rb lib/xmpp4r/pubsub/children/publish.rb lib/xmpp4r/pubsub/helper/oauth_service_helper.rb lib/xmpp4r/pubsub/children/event.rb lib/xmpp4r/pubsub/iq/pubsub.rb lib/xmpp4r/pubsub/children/retract.rb lib/xmpp4r/pubsub/helper/nodebrowser.rb lib/xmpp4r/pubsub/helper/nodehelper.rb lib/xmpp4r/pubsub/children/items.rb lib/xmpp4r/pubsub/children/subscription_config.rb lib/xmpp4r/pubsub/children/node_config.rb OAuthPubSubStreamHelper PubSub lib/xmpp4r/httpbinding/client.rb HTTPBinding lib/xmpp4r/tune/helper/helper.rb lib/xmpp4r/tune/tune.rb UserTune lib/xmpp4r/sasl.rb SASL lib/xmpp4r/test/listener_mocker.rb Test lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/discovery/helper/helper.rb lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/helper/responder.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/last/helper/helper.rb lib/xmpp4r/last/iq/last.rb LastActivity lib/xmpp4r/framework/base.rb lib/xmpp4r/framework/bot.rb Framework lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber dot/m_110_0.png

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

Methods

body   body=   chat_state   chat_state=   new   set_body   set_chat_state   set_subject   set_thread   set_type   subject   subject=   thread   thread=   type   type=  

Included Modules

XParent

Constants

CHAT_STATES = %w(active composing gone inactive paused).freeze

Public Class methods

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 25
25:     def initialize(to = nil, body = nil)
26:       super()
27:       if not to.nil?
28:         set_to(to)
29:       end
30:       if !body.nil?
31:         add_element(REXML::Element.new("body").add_text(body))
32:       end
33:     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 81
81:     def body
82:       first_element_text('body')
83:     end

Sets the message‘s body

b:[String] body to set

[Source]

    # File lib/xmpp4r/message.rb, line 89
89:     def body=(b)
90:       replace_element_text('body', b)
91:     end

Returns the current chat state, or nil if no chat state is set

[Source]

     # File lib/xmpp4r/message.rb, line 152
152:     def chat_state
153:       each_elements(*CHAT_STATES) { |el| return el.name.to_sym }
154:       return nil
155:     end

Sets the chat state :active, :composing, :gone, :inactive, :paused

[Source]

     # File lib/xmpp4r/message.rb, line 159
159:     def chat_state=(s)
160:       s = s.to_s
161:       raise InvalidChatState, "Chat state must be one of #{CHAT_STATES.join(', ')}" unless CHAT_STATES.include?(s)
162:       CHAT_STATES.each { |state| delete_elements(state) }
163:       add_element(REXML::Element.new(s).add_namespace('http://jabber.org/protocol/chatstates'))
164:     end

Sets the message‘s body

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

[Source]

     # File lib/xmpp4r/message.rb, line 98
 98:     def set_body(b)
 99:       self.body = b
100:       self
101:     end

Sets the message‘s chat state

[Source]

     # File lib/xmpp4r/message.rb, line 168
168:     def set_chat_state(s)
169:       self.state = s
170:       self
171:     end

sets the message‘s subject

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

[Source]

     # File lib/xmpp4r/message.rb, line 116
116:     def set_subject(s)
117:       self.subject = s
118:       self
119:     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 139
139:     def set_thread(s)
140:       self.thread = s
141:       self
142:     end

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

v:[Symbol] or nil

[Source]

    # File lib/xmpp4r/message.rb, line 73
73:     def set_type(v)
74:       self.type = v
75:       self
76:     end

Returns the message‘s subject, or nil

[Source]

     # File lib/xmpp4r/message.rb, line 123
123:     def subject
124:       first_element_text('subject')
125:     end

sets the message‘s subject

s:[String] subject to set

[Source]

     # File lib/xmpp4r/message.rb, line 107
107:     def subject=(s)
108:       replace_element_text('subject', s)
109:     end

Returns the message‘s thread, or nil

[Source]

     # File lib/xmpp4r/message.rb, line 146
146:     def thread
147:       first_element_text('thread')
148:     end

sets the message‘s thread

s:[String] thread to set

[Source]

     # File lib/xmpp4r/message.rb, line 130
130:     def thread=(s)
131:       delete_elements('thread')
132:       replace_element_text('thread', s) unless s.nil?
133:     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 45
45:     def type
46:       case super
47:         when 'chat' then :chat
48:         when 'error' then :error
49:         when 'groupchat' then :groupchat
50:         when 'headline' then :headline
51:         when 'normal' then :normal
52:         else nil
53:       end
54:     end

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

v:[Symbol] or nil

[Source]

    # File lib/xmpp4r/message.rb, line 59
59:     def type=(v)
60:       case v
61:         when :chat then super('chat')
62:         when :error then super('error')
63:         when :groupchat then super('groupchat')
64:         when :headline then super('headline')
65:         when :normal then super('normal')
66:         else super(nil)
67:       end
68:     end

[Validate]