Class: Jabber::MUC::HipChat::Presence

Inherits:
Presence
  • Object
show all
Defined in:
lib/xmpp4r/muc/hipchat/presence.rb

Instance Method Summary collapse

Constructor Details

#initialize(my_jid) ⇒ Presence

Returns a new instance of Presence.



5
6
7
8
9
# File 'lib/xmpp4r/muc/hipchat/presence.rb', line 5

def initialize my_jid
  super(:chat)
  @my_jid   = my_jid
  self.from = my_jid
end

Instance Method Details

#get_join(jid, fetch_history = false) ⇒ Object



15
16
17
# File 'lib/xmpp4r/muc/hipchat/presence.rb', line 15

def get_join jid, fetch_history = false
  get_status(:available, room_jid(jid)) # TODO: Handle all join responses
end

#get_leave(jid, reason = nil) ⇒ Object



11
12
13
# File 'lib/xmpp4r/muc/hipchat/presence.rb', line 11

def get_leave jid, reason = nil
  get_status(:unavailable, room_jid(jid), reason)
end

#get_status(type, to = nil, status = nil, fetch_history = false) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/xmpp4r/muc/hipchat/presence.rb', line 19

def get_status type, to = nil, status = nil, fetch_history = false
  self.dup.tap do |d|
    d.set_status(status)
    d.set_type(type)
    d.no_history! unless fetch_history
    d.to = to
  end
end

#no_history!Object



28
29
30
31
32
33
34
35
36
# File 'lib/xmpp4r/muc/hipchat/presence.rb', line 28

def no_history!
  element = REXML::Element.new('history').tap do |h|
    h.add_attribute('maxstanzas', '0')
  end

  xmuc = XMUC.new
  xmuc.add_element(element)
  self.add(xmuc)
end

#send_to(stream, &block) ⇒ Object



38
39
40
# File 'lib/xmpp4r/muc/hipchat/presence.rb', line 38

def send_to stream, &block
  stream.send(self, &block)
end