Class: AgentXmpp::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/agent_xmpp/models/subscription.rb

Overview


Class Method Summary collapse

Class Method Details

.destroy_by_node(node) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



29
30
31
# File 'lib/agent_xmpp/models/subscription.rb', line 29

def destroy_by_node(node)
  subscriptions.filter(:node => node).delete
end

.find_allObject

.….….….….….….….….….….….….….….….….….….….….….….….….….….



16
17
18
# File 'lib/agent_xmpp/models/subscription.rb', line 16

def find_all
  subscriptions.all
end

.stats_by_nodeObject

.….….….….….….….….….….….….….….….….….….….….….….….….….….



34
35
36
37
38
39
# File 'lib/agent_xmpp/models/subscription.rb', line 34

def stats_by_node
  find_all.map do |s|
    node = s[:node].split('/')
    Message.stats_by_node(s[:node]).update(:node=>node.last, :jid=>"#{node[3]}@#{node[2]}")
  end
end

.subscriptions(renew = false) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



11
12
13
# File 'lib/agent_xmpp/models/subscription.rb', line 11

def subscriptions(renew=false)
  @subscriptions ||= AgentXmpp.in_memory_db[:subscriptions]
end

.update(msg, node, serv) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



21
22
23
24
25
26
# File 'lib/agent_xmpp/models/subscription.rb', line 21

def update(msg, node, serv)
  case msg
    when AgentXmpp::Xmpp::Subscription then update_with_subscription(msg, node, serv)
    when AgentXmpp::Xmpp::Iq then update_with_subscription(msg.pubsub.subscription, node, serv)
  end                 
end

.update_with_subscription(msg, node, serv) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….…. private .….….….….….….….….….….….….….….….….….….….….….….….….….….



44
45
46
47
48
49
# File 'lib/agent_xmpp/models/subscription.rb', line 44

def update_with_subscription(msg, node, serv)
  begin
    subscriptions << {:node => node, :subscription => msg.subscription, :service => serv}
  rescue 
  end
end