Class: ScoutAgent::Agent::CommunicationAgent

Inherits:
ScoutAgent::Agent show all
Defined in:
lib/scout_agent/agent/communication_agent.rb

Constant Summary collapse

RECONNECT_WAIT =
60

Instance Attribute Summary

Attributes inherited from ScoutAgent::Agent

#log

Instance Method Summary collapse

Methods inherited from ScoutAgent::Agent

#authorize, #notice_changes

Methods included from Tracked

#clear_status, #force_status_database_reload, #status, #status_database, #status_log

Constructor Details

#initializeCommunicationAgent

Returns a new instance of CommunicationAgent.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/scout_agent/agent/communication_agent.rb', line 13

def initialize
  super  # setup our log and status

  Order.log = log  # pass on our log
  Order.load_all   # load supported orders
  
  @agent_jid       = nil
  @jabber          = nil
  @roster          = nil
  @shutdown_thread = nil
end

Instance Method Details

#finishObject



35
36
37
38
39
40
41
# File 'lib/scout_agent/agent/communication_agent.rb', line 35

def finish
  if @shutdown_thread
    @shutdown_thread.run
  else
    exit
  end
end

#runObject



25
26
27
28
29
30
31
32
33
# File 'lib/scout_agent/agent/communication_agent.rb', line 25

def run
  
  update_status("Online since #{Time.now.utc.to_db_s}")
  fetch_roster
  install_subscriptions_callback
  install_messages_callback
  listen
  close_connection
end