Class: Jabber::MUC::HipChat::Message
- Inherits:
-
Jabber::Message
- Object
- Jabber::Message
- Jabber::MUC::HipChat::Message
- Defined in:
- lib/xmpp4r/muc/hipchat/message.rb
Instance Method Summary collapse
- #add_recipient(jid) ⇒ Object
- #get_invite(room_jid, recipient_jids) ⇒ Object
- #get_text(type, jid, text, subject = nil) ⇒ Object
-
#initialize(my_jid) ⇒ Message
constructor
A new instance of Message.
- #send_to(stream, &block) ⇒ Object
Constructor Details
#initialize(my_jid) ⇒ Message
Returns a new instance of Message.
5 6 7 8 9 10 |
# File 'lib/xmpp4r/muc/hipchat/message.rb', line 5 def initialize my_jid super() @my_jid = my_jid self.from = my_jid @semaphore = Mutex.new end |
Instance Method Details
#add_recipient(jid) ⇒ Object
34 35 36 |
# File 'lib/xmpp4r/muc/hipchat/message.rb', line 34 def add_recipient jid xmuc_user.add(XMUCUserInvite.new(jid)) end |
#get_invite(room_jid, recipient_jids) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/xmpp4r/muc/hipchat/message.rb', line 24 def get_invite room_jid, recipient_jids self.dup.tap do |d| d.to = JID.new(room_jid) recipient_jids.each do |recipient_jid| d.add_recipient(recipient_jid) end end end |
#get_text(type, jid, text, subject = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/xmpp4r/muc/hipchat/message.rb', line 12 def get_text type, jid, text, subject = nil self.dup.tap do |d| recipient = JID.new(jid) recipient.resource ||= recipient.node d.body = text.to_s d.to = recipient d.type = type d.subject = subject if subject end end |
#send_to(stream, &block) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/xmpp4r/muc/hipchat/message.rb', line 38 def send_to stream, &block Thread.new do @semaphore.synchronize { stream.send(self, &block) sleep(0.2) } end end |