Module: AgentXmpp
- Defined in:
- lib/agent_xmpp/xmpp/iq.rb,
lib/agent_xmpp/main.rb,
lib/agent_xmpp/config.rb,
lib/agent_xmpp/xmpp/jid.rb,
lib/agent_xmpp/xmpp/sasl.rb,
lib/agent_xmpp/xmpp/entry.rb,
lib/agent_xmpp/client/boot.rb,
lib/agent_xmpp/xmpp/stanza.rb,
lib/agent_xmpp/xmpp/x_data.rb,
lib/agent_xmpp/xmpp/element.rb,
lib/agent_xmpp/xmpp/message.rb,
lib/agent_xmpp/client/client.rb,
lib/agent_xmpp/models/roster.rb,
lib/agent_xmpp/xmpp/iq_disco.rb,
lib/agent_xmpp/xmpp/presence.rb,
lib/agent_xmpp/models/contact.rb,
lib/agent_xmpp/models/message.rb,
lib/agent_xmpp/models/service.rb,
lib/agent_xmpp/xmpp/iq_pubsub.rb,
lib/agent_xmpp/xmpp/iq_roster.rb,
lib/agent_xmpp/client/response.rb,
lib/agent_xmpp/xmpp/iq_command.rb,
lib/agent_xmpp/xmpp/iq_version.rb,
lib/agent_xmpp/client/connection.rb,
lib/agent_xmpp/client/controller.rb,
lib/agent_xmpp/models/publication.rb,
lib/agent_xmpp/client/message_pipe.rb,
lib/agent_xmpp/models/subscription.rb,
lib/agent_xmpp/xmpp/error_response.rb,
lib/agent_xmpp/client/message_delegate.rb,
lib/agent_xmpp/models/table_definitions.rb
Overview
Original from XMPP4R - XMPP Library for Ruby Website::home.gna.org/xmpp4r/
Defined Under Namespace
Modules: Delegator, Xmpp Classes: AgentXmppError, BaseController, Boot, Client, Connection, Contact, Controller, Delegate, Error, Message, MessageDelegate, MessagePipe, Publication, Response, Roster, Service, Subscription
Constant Summary collapse
- VERSION =
.….….….….….….….….….….….….….….….….….….….….….….….….….….
"0.1.1"
- AGENT_XMPP_NAME =
'AgentXMPP'
- OS_VERSION =
IO.popen('uname -sr').readlines.first.to_s.strip
- SUBSCRIBE_RETRY_PERIOD =
60
- IDENTITY =
{:category => 'client', :name => AGENT_XMPP_NAME, :type => 'bot'}
- FEATURES =
['http://jabber.org/protocol/disco#info', 'http://jabber.org/protocol/disco#items', 'jabber:iq:version', 'jabber:x:data', 'http://jabber.org/protocol/commands', 'http://jabber.org/protocol/pubsub', 'http://jabber.org/protocol/pubsub#publish', 'http://jabber.org/protocol/pubsub#subscribe', 'http://jabber.org/protocol/pubsub#create-nodes', 'http://jabber.org/protocol/pubsub#delete-nodes']
- GARBAGE_COLLECTION_INTERVAL =
86400
- DEFAULT_PUBSUB_CONFIG =
{ :title => 'event', :access_model => 'presence', :max_items => 20, :deliver_notifications => 1, :deliver_payloads => 1, :persist_items => 1, :subscribe => 1, :notify_config => 0, :notify_delete => 0, :notify_retract => 0, }
Class Attribute Summary collapse
-
.app_path ⇒ Object
Returns the value of attribute app_path.
-
.config ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.config_file ⇒ Object
Returns the value of attribute config_file.
-
.log_file ⇒ Object
Returns the value of attribute log_file.
-
.settings ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Class Method Summary collapse
-
.agent_xmpp_db ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.bare_jid_to_s(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.create_agent_xmpp_db ⇒ Object
—————————————————————————————————–.
-
.create_in_memory_db ⇒ Object
—————————————————————————————————–.
-
.full_jid_to_s(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.in_memory_db ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….
-
.is_account_jid?(jid) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….….
-
.jid ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.jid=(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
- .logger ⇒ Object
- .logger=(logger) ⇒ Object
-
.password ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.port ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.priority ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.publication ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.pubsub_root ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….
-
.resource ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.set(key, value) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….
-
.start_garbage_collection(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.upgrade_agent_xmpp_db ⇒ Object
—————————————————————————————————–.
-
.user_pubsub_root ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.version ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Class Attribute Details
.app_path ⇒ Object
Returns the value of attribute app_path.
39 40 41 |
# File 'lib/agent_xmpp/config.rb', line 39 def app_path @app_path end |
.config ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
25 26 27 |
# File 'lib/agent_xmpp/main.rb', line 25 def config @config end |
.config_file ⇒ Object
Returns the value of attribute config_file.
39 40 41 |
# File 'lib/agent_xmpp/config.rb', line 39 def config_file @config_file end |
.log_file ⇒ Object
Returns the value of attribute log_file.
39 40 41 |
# File 'lib/agent_xmpp/config.rb', line 39 def log_file @log_file end |
.settings ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
25 26 27 |
# File 'lib/agent_xmpp/main.rb', line 25 def settings @settings end |
Class Method Details
.agent_xmpp_db ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
42 43 44 45 46 47 48 |
# File 'lib/agent_xmpp/main.rb', line 42 def agent_xmpp_db @agent_xmpp_db ||= if settings[:agent_xmpp_db_adapter] settings[:agent_xmpp_db_adapter].call else Sequel.sqlite("#{AgentXmpp.app_path}/agent_xmpp.db") end end |
.bare_jid_to_s(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
118 119 120 121 122 123 124 |
# File 'lib/agent_xmpp/main.rb', line 118 def (jid) case jid when String then Xmpp::Jid.new(jid)..to_s when Xmpp::Jid then jid..to_s else jid end end |
.create_agent_xmpp_db ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/agent_xmpp/models/table_definitions.rb', line 67 def create_agent_xmpp_db unless agent_xmpp_db.table_exists? :version agent_xmpp_db.create_table :version do primary_key :id integer :number end end version << {:number=>1} if version.count.eql?(0) unless agent_xmpp_db.table_exists? :contacts agent_xmpp_db.create_table :contacts do primary_key :id column :jid, :text, :unique=>true column :ask, :text column :subscription, :text column :groups, :text end end unless agent_xmpp_db.table_exists? :messages agent_xmpp_db.create_table :messages do primary_key :id column :message_text, :text column :content_type, :text column :message_type, :text column :to_jid, :text column :from_jid, :text column :node, :text column :item_id, :text Time :created_at end end end |
.create_in_memory_db ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/agent_xmpp/models/table_definitions.rb', line 8 def create_in_memory_db in_memory_db.create_table :roster do primary_key :id column :contact_id, :integer column :jid, :text, :unique=>true column :status, :text column :client_name, :text column :client_version, :text column :client_os, :text end in_memory_db.create_table :services do primary_key :id column :jid, :text column :name, :text column :category, :text column :type, :text column :node, :text unique [:node, :jid] end in_memory_db.create_table :service_items do primary_key :id column :parent_node, :text column :service, :text column :node, :text column :jid, :text column :name, :text unique [:node, :service] end in_memory_db.create_table :service_features do primary_key :id column :node, :text column :service, :text column :var, :text unique [:node, :service, :var] end in_memory_db.create_table :publications do primary_key :id column :node, :text, :unique=>true column :status, :text column :title, :text column :access_model, :text column :max_items, :integer column :deliver_notifications, :integer column :deliver_payloads, :integer column :persist_items, :integer column :subscribe, :integer column :notify_config, :integer column :notify_delete, :integer column :notify_retract, :integer end in_memory_db.create_table :subscriptions do primary_key :id column :node, :text, :unique=>true column :service, :text column :subscription, :text end end |
.full_jid_to_s(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
127 128 129 130 131 132 133 |
# File 'lib/agent_xmpp/main.rb', line 127 def full_jid_to_s(jid) case jid when String then jid when Xmpp::Jid then jid.to_s else jid end end |
.in_memory_db ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….…. database .….….….….….….….….….….….….….….….….….….….….….….….….….….
37 38 39 |
# File 'lib/agent_xmpp/main.rb', line 37 def in_memory_db @in_memory_db ||= Sequel.sqlite end |
.is_account_jid?(jid) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….…. client account configuration .….….….….….….….….….….….….….….….….….….….….….….….….….….
75 76 77 |
# File 'lib/agent_xmpp/main.rb', line 75 def is_account_jid?(jid) @jid..to_s.eql?((jid)) end |
.jid ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
80 81 82 |
# File 'lib/agent_xmpp/main.rb', line 80 def jid @jid ||= Xmpp::Jid.new("#{config['jid']}/#{resource}") end |
.jid=(jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
85 86 87 |
# File 'lib/agent_xmpp/main.rb', line 85 def jid=(jid) @jid = jid end |
.logger ⇒ Object
40 |
# File 'lib/agent_xmpp/config.rb', line 40 def logger; @logger ||= Logger.new(STDOUT); end |
.logger=(logger) ⇒ Object
41 |
# File 'lib/agent_xmpp/config.rb', line 41 def logger=(logger); @logger = logger; end |
.password ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
100 101 102 |
# File 'lib/agent_xmpp/main.rb', line 100 def password config['password'] end |
.port ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
95 96 97 |
# File 'lib/agent_xmpp/main.rb', line 95 def port config['port'] || 5222 end |
.priority ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/agent_xmpp/main.rb', line 105 def priority @priority ||= if config['priority'] if config['priority'] < -127 -127 elsif config['priority'] > 128 128 else config['priority'] end else; 1; end end |
.publication ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
56 57 58 |
# File 'lib/agent_xmpp/main.rb', line 56 def publication @publication ||= PublishModel.new(config['publish']) end |
.pubsub_root ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….…. pubsub nodes .….….….….….….….….….….….….….….….….….….….….….….….….….….
63 64 65 |
# File 'lib/agent_xmpp/main.rb', line 63 def pubsub_root @pubsub_root ||= "/home/#{AgentXmpp.jid.domain}" end |
.resource ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
90 91 92 |
# File 'lib/agent_xmpp/main.rb', line 90 def resource config['resource'] || Socket.gethostname end |
.set(key, value) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….…. settings .….….….….….….….….….….….….….….….….….….….….….….….….….….
30 31 32 |
# File 'lib/agent_xmpp/main.rb', line 30 def set(key, value) @settings[key] = value end |
.start_garbage_collection(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/agent_xmpp/main.rb', line 136 def start_garbage_collection(pipe) EventMachine::PeriodicTimer.new(AgentXmpp::GARBAGE_COLLECTION_INTERVAL) do AgentXmpp.logger.info "GARBAGE COLLECTION IN PROGRESS ON INTERVAL: #{AgentXmpp::GARBAGE_COLLECTION_INTERVAL}" AgentXmpp::BaseController.commands_list.each do |(session, command_info)| AgentXmpp::BaseController.remove_command_from_list(session) if Time.now - command_info[:created_at] > AgentXmpp::GARBAGE_COLLECTION_INTERVAL end pipe.responder_list.each do |(stanza_id, command_info)| pipe.remove_from_responder_list(stanza_id) if Time.now - command_info[:created_at] > AgentXmpp::GARBAGE_COLLECTION_INTERVAL end end end |
.upgrade_agent_xmpp_db ⇒ Object
100 101 |
# File 'lib/agent_xmpp/models/table_definitions.rb', line 100 def upgrade_agent_xmpp_db end |
.user_pubsub_root ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
68 69 70 |
# File 'lib/agent_xmpp/main.rb', line 68 def user_pubsub_root @user_pubsub_root ||= "#{@pubsub_root}/#{AgentXmpp.jid.node}" end |
.version ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
51 52 53 |
# File 'lib/agent_xmpp/main.rb', line 51 def version @version ||= agent_xmpp_db[:version] end |