Class: Jabber::LastActivity::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/xmpp4r/last/helper/helper.rb

Overview

A Helper to manage discovery of Last Activity.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Helper

Returns a new instance of Helper.



13
14
15
# File 'lib/xmpp4r/last/helper/helper.rb', line 13

def initialize(client)
  @stream = client
end

Instance Method Details

#get_last_activity_from(jid) ⇒ Object

Gets the last activity from a JID.

jid
JID
return
Jabber::LastActivity::IqQueryLastActivity


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/xmpp4r/last/helper/helper.rb', line 21

def get_last_activity_from(jid)
  iq = Jabber::Iq.new(:get, jid)
  iq.from = @stream.jid
  iq.add(Jabber::LastActivity::IqQueryLastActivity.new)

  reply = @stream.send_with_id(iq)

  if reply.query && reply.query.kind_of?(IqQueryLastActivity)
    reply.query
  else
    nil
  end
end