Class: AgentXmpp::MessageDelegate
- Defined in:
- lib/agent_xmpp/client/message_delegate.rb
Overview
Class Attribute Summary collapse
-
.pubsub_service ⇒ Object
readonly
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Class Method Summary collapse
-
.add_create_pubsub_node(pipe, pubsub) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.add_publish_method(pipe, pubsub) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.add_publish_methods(pipe, pubsub) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.add_send_chat_method(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.add_send_command_request_method(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.check_roster_item_group(pipe, roster_item) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.create_user_pubsub_root(pipe, pubsub, items) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.init_remote_services(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_all_roster_items(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_authenticate(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_bind(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_command_set(pipe, stanza) ⇒ Object
——————————————————————————————————— event flow delegate methods .….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_connect(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_did_not_authenticate(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_did_not_connect(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_discoinfo_error(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_discoinfo_get(pipe, request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_discoinfo_result(pipe, discoinfo) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_discoitems_error(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_discoitems_get(pipe, request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_discoitems_result(pipe, discoitems) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_disconnect(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_discovery_of_pupsub_collection(pipe, jid, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_discovery_of_pupsub_leaf(pipe, jid, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_discovery_of_pupsub_service(pipe, jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_discovery_of_user_pubsub_root(pipe, pubsub, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_message_chat(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_message_headline(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_message_normal(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_postauthenticate_features(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_preauthenticate_features(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_presence(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_presence_error(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_presence_subscribe(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_presence_subscribed(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_presence_unavailable(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_presence_unsubscribed(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_publish_error(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_publish_result(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_affiliations_error(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_affiliations_result(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_create_node_error(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_create_node_result(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_delete_node_error(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_delete_node_result(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_event(pipe, event, to, from) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_subscribe_error(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_subscribe_error_item_not_found(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_subscribe_result(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_subscriptions_error(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_subscriptions_result(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_unsubscribe_error(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_pubsub_unsubscribe_result(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_remove_roster_item(pipe, roster_item) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_remove_roster_item_error(pipe, roster_item_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_remove_roster_item_result(pipe, roster_item_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_roster_item(pipe, roster_item) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_roster_result(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_roster_set(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_start_session(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_unsupported_message(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_update_roster_item_error(pipe, roster_item_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_update_roster_item_result(pipe, roster_item_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_version_error(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_version_get(pipe, request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.on_version_result(pipe, version) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.process_pubsub_discoinfo(type, pipe, from, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.process_roster_items(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.update_publish_nodes(pipe, pubsub, items) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Class Attribute Details
.pubsub_service ⇒ Object (readonly)
.….….….….….….….….….….….….….….….….….….….….….….….….….….
11 12 13 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 11 def pubsub_service @pubsub_service end |
Class Method Details
.add_create_pubsub_node(pipe, pubsub) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
664 665 666 667 668 669 670 671 672 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 664 def add_create_pubsub_node(pipe, pubsub) unless AgentXmpp.respond_to?(:create_pubsub_node) AgentXmpp.(:create_pubsub_node) do |node| pipe.send_resp(Xmpp::IqPubSub.create_node(pipe, pubsub, node)) end AgentXmpp.logger.info "ADDED CREATE_PUBSUB_NODE FOR: #{pubsub}" Delegator.delegate(AgentXmpp, :create_pubsub_node) end end |
.add_publish_method(pipe, pubsub) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
653 654 655 656 657 658 659 660 661 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 653 def add_publish_method(pipe, pubsub) unless AgentXmpp.respond_to?(:publish) AgentXmpp.(:publish) do |node, payload| pipe.send_resp(Xmpp::IqPublish.set(pipe, :node => node, :to => pubsub, :payload => payload.to_x_data)) end AgentXmpp.logger.info "ADDED PUBLISH METHOD FOR: #{pubsub}" Delegator.delegate(AgentXmpp, :publish) end end |
.add_publish_methods(pipe, pubsub) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 633 def add_publish_methods(pipe, pubsub) Publication.find_all.each do |pub| if pub[:node] meth = ("publish_" + pub[:node].gsub(/-/,'_')).to_sym unless AgentXmpp.respond_to?(meth) AgentXmpp.(meth) do |payload| pipe.send_resp(Xmpp::IqPublish.set(pipe, :node => pub[:node], :to => pubsub, :payload => payload.to_x_data)) end AgentXmpp.logger.info "ADDED PUBLISH METHOD FOR NODE: #{pub[:node]}, #{pubsub}" Delegator.delegate(AgentXmpp, meth) else AgentXmpp.logger.warn "PUBLISH METHOD FOR NODE EXISTS: #{pub[:node]}, #{pubsub}" end else AgentXmpp.logger.warn "NODE NOT SPECIFIED FOR PUBSUB PUBLISH CONFIGURATION" end end end |
.add_send_chat_method(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
685 686 687 688 689 690 691 692 693 694 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 685 def add_send_chat_method(pipe) AgentXmpp.(:send_chat) do |args| raise ArgmentError ':to and :body are required' unless args[:to] and args[:body] = Xmpp::Message.new(args[:to], args[:body]) .type = args[:type] || :chat pipe.send_resp(Send()) end Delegator.delegate(AgentXmpp, :send_chat) AgentXmpp.logger.info "ADDED MESSAGE METHOD" end |
.add_send_command_request_method(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
675 676 677 678 679 680 681 682 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 675 def add_send_command_request_method(pipe) AgentXmpp.(:send_command_request) do |args, &blk| pipe.send_resp(Xmpp::IqCommand.send_command(:to=>args[:to], :node=>args[:node], :iq_type=>:set, :action=>:execute, :payload=>args[:payload], &blk)) end Delegator.delegate(AgentXmpp, :send_command_request) AgentXmpp.logger.info "ADDED SEND_COMMAND_REQUEST METHOD" end |
.check_roster_item_group(pipe, roster_item) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. private .….….….….….….….….….….….….….….….….….….….….….….….….….….
606 607 608 609 610 611 612 613 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 606 def check_roster_item_group(pipe, roster_item) roster_item_jid = roster_item.jid roster_item_groups = Contact.find_by_jid(roster_item_jid)[:groups].split(/,/).sort unless roster_item.groups.sort.eql?(roster_item_groups) AgentXmpp.logger.info "CHANGE IN ROSTER ITEM GROUP FOUND UPDATING: #{roster_item_jid.to_s} to '#{roster_item_groups.join(', ')}'" Xmpp::IqRoster.update(pipe, roster_item_jid.to_s, roster_item_groups) end end |
.create_user_pubsub_root(pipe, pubsub, items) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
697 698 699 700 701 702 703 704 705 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 697 def create_user_pubsub_root(pipe, pubsub, items) if (roots = items.select{|i| i.node.eql?(AgentXmpp.user_pubsub_root)}).empty? AgentXmpp.logger.info "USER PUBSUB ROOT NOT FOUND CREATING NODE: #{pubsub.to_s}, #{AgentXmpp.user_pubsub_root}" [Xmpp::IqPubSub.create_node(pipe, pubsub.to_s, AgentXmpp.user_pubsub_root)] else AgentXmpp.logger.info "USER PUBSUB ROOT FOUND: #{pubsub.to_s}, #{AgentXmpp.user_pubsub_root}" on_discovery_of_user_pubsub_root(pipe, pubsub, AgentXmpp.user_pubsub_root); [] end end |
.init_remote_services(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
726 727 728 729 730 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 726 def init_remote_services(pipe) (BaseController.event_domains-[AgentXmpp.jid.domain]).map do |d| Xmpp::IqDiscoInfo.get(pipe, d) end end |
.on_all_roster_items(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
289 290 291 292 293 294 295 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 289 def on_all_roster_items(pipe) AgentXmpp.logger.info "RECEIVED ALL ROSTER ITEMS" Contact.find_all_by_subscription(:new).map do |r| AgentXmpp.logger.info "ADDING CONTACT: #{r[:jid]}" [Xmpp::IqRoster.update(pipe, r[:jid], r[:groups].split(/,/)), Xmpp::Presence.subscribe(r[:jid])] end end |
.on_authenticate(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
139 140 141 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 139 def on_authenticate(pipe) AgentXmpp.logger.info "AUTHENTICATED" end |
.on_bind(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. authentication .….….….….….….….….….….….….….….….….….….….….….….….….….….
127 128 129 130 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 127 def on_bind(pipe) AgentXmpp.logger.info "DID BIND TO RESOURCE: #{AgentXmpp.jid.resource}" Xmpp::Iq.session(pipe) if pipe.stream_features.has_key?('session') end |
.on_command_set(pipe, stanza) ⇒ Object
event flow delegate methods .….….….….….….….….….….….….….….….….….….….….….….….….….…. process command .….….….….….….….….….….….….….….….….….….….….….….….….….….
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 18 def on_command_set(pipe, stanza) command = stanza.command params = {:xmlns => 'jabber:x:data', :action => command.action || :execute, :to => stanza.from.to_s, :from => stanza.from.to_s, :node => command.node, :id => stanza.id, :sessionid => command.sessionid} (data = command.x) ? params.update(:data=>data.to_params, :x_data_type => data.type) : params.update(:data=>{}) AgentXmpp.logger.info "RECEIVED COMMAND NODE: #{command.node}, FROM: #{stanza.from.to_s}" if BaseController.commands_list[params[:sessionid]] BaseController.commands_list[params[:sessionid]][:controller].next(params).invoke_command_next else Controller.new(pipe, params).invoke_command end end |
.on_connect(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. connection .….….….….….….….….….….….….….….….….….….….….….….….….….….
109 110 111 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 109 def on_connect(pipe) AgentXmpp.logger.info "CONNECTED" end |
.on_did_not_authenticate(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
144 145 146 147 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 144 def on_did_not_authenticate(pipe) AgentXmpp.logger.info "AUTHENTICATION FAILED" raise AgentXmppError, "authentication failed" end |
.on_did_not_connect(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
120 121 122 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 120 def on_did_not_connect(pipe) AgentXmpp.logger.warn "CONNECTION FAILED" end |
.on_discoinfo_error(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
395 396 397 398 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 395 def on_discoinfo_error(pipe, result) from_jid = result.from AgentXmpp.logger.warn "RECEIVED DISCO INFO ERROR FROM: #{from_jid.to_s}, #{result.query.node}" end |
.on_discoinfo_get(pipe, request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 345 def on_discoinfo_get(pipe, request) from_jid = request.from if Contact.has_jid?(from_jid) or AgentXmpp.is_account_jid?(from_jid) if request.query.node.nil? AgentXmpp.logger.info "RECEIVED DISCO INFO REQUEST FROM: #{from_jid.to_s}" Xmpp::IqDiscoInfo.result(pipe, request) else AgentXmpp.logger.info "RECEIVED DISCO INFO REQUEST FOR UNSUPPORTED NODE FROM: #{from_jid.to_s}" Xmpp::ErrorResponse.item_not_found(request) end else AgentXmpp.logger.warn "RECEIVED DISCO INFO REQUEST FROM JID NOT IN ROSTER: #{from_jid.to_s}" Xmpp::ErrorResponse.service_unavailable(request) end end |
.on_discoinfo_result(pipe, discoinfo) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 362 def on_discoinfo_result(pipe, discoinfo) from_jid = discoinfo.from do_discoitems = true request = [] q = discoinfo.query AgentXmpp.logger.info "RECEIVED DISCO INFO RESULT FROM: #{from_jid.to_s}" + (q.node.nil? ? '' : ", NODE: #{q.node}") Service.update(discoinfo) q.identities.each do |i| AgentXmpp.logger.info " IDENTITY: NAME:#{i.iname}, CATEGORY:#{i.category}, TYPE:#{i.type}" request << case i.category when 'server' then Xmpp::IqDiscoItems.get(pipe, from_jid.to_s, q.node) when 'pubsub' then process_pubsub_discoinfo(i.type, pipe, from_jid, q.node) when 'conference' when 'proxy' when 'directory' when 'client' when 'automation' when 'auth' when 'collaboration' when 'componenet' when 'gateway' when 'hierarchy' when 'headline' when 'store' end end q.features.each do |f| AgentXmpp.logger.info " FEATURE: #{f}" end request.smash end |
.on_discoitems_error(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
444 445 446 447 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 444 def on_discoitems_error(pipe, result) from_jid = result.from AgentXmpp.logger.warn "RECEIVED DISCO ITEMS ERROR FROM: #{from_jid.to_s}" end |
.on_discoitems_get(pipe, request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 401 def on_discoitems_get(pipe, request) from_jid = request.from if Contact.has_jid?(from_jid) or AgentXmpp.is_account_jid?(from_jid) if request.query.node.eql?('http://jabber.org/protocol/commands') AgentXmpp.logger.info "RECEIVED COMMAND NODE DISCO ITEMS REQUEST FROM: #{from_jid.to_s}" Xmpp::IqDiscoItems.result_command_nodes(pipe, request) elsif request.query.node.nil? AgentXmpp.logger.info "RECEIVED DISCO ITEMS REQUEST FROM: #{from_jid.to_s}" Xmpp::IqDiscoItems.result(pipe, request) else AgentXmpp.logger.info "RECEIVED DISCO INFO REQUEST FOR UNSUPPORTED NODE FROM: #{from_jid.to_s}" Xmpp::ErrorResponse.item_not_found(request) end else AgentXmpp.logger.warn "RECEIVED DISCO ITEMS REQUEST FROM JID NOT IN ROSTER: #{from_jid.to_s}" Xmpp::ErrorResponse.service_unavailable(request) end end |
.on_discoitems_result(pipe, discoitems) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 421 def on_discoitems_result(pipe, discoitems) from_jid = discoitems.from q = discoitems.query AgentXmpp.logger.info "RECEIVED DISCO ITEMS RESULT FROM: #{from_jid.to_s}" + (q.node.nil? ? '' : ", NODE: #{q.node}") Service.update(discoitems) case q.node when 'http://jabber.org/protocol/commands' Boot.call_if_implemented(:call_discovered_command_nodes, from_jid.to_s, q.items.map{|i| i.node}) unless q.items.empty? else msgs = if from_jid.to_s.eql?(pubsub_service.to_s) and q.node.eql?(AgentXmpp.pubsub_root) create_user_pubsub_root(pipe, from_jid, q.items) else ; []; end if from_jid.to_s.eql?(pubsub_service.to_s) and q.node.eql?(AgentXmpp.user_pubsub_root) msgs += update_publish_nodes(pipe, from_jid, q.items) end q.items.inject(msgs) do |r,i| AgentXmpp.logger.info " ITEM JID: #{i.jid}" + (i.node.nil? ? '' : ", NODE: #{i.node}") r << Xmpp::IqDiscoInfo.get(pipe, i.jid, i.node) end end end |
.on_disconnect(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
114 115 116 117 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 114 def on_disconnect(pipe) AgentXmpp.logger.warn "DISCONNECTED" EventMachine::stop_event_loop end |
.on_discovery_of_pupsub_collection(pipe, jid, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
475 476 477 478 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 475 def on_discovery_of_pupsub_collection(pipe, jid, node) AgentXmpp.logger.info "DISCOVERED PUBSUB COLLECTION: #{jid}, #{node}" Xmpp::IqDiscoItems.get(pipe, jid, node) if pubsub_service.eql?(jid) end |
.on_discovery_of_pupsub_leaf(pipe, jid, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
481 482 483 484 485 486 487 488 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 481 def on_discovery_of_pupsub_leaf(pipe, jid, node) AgentXmpp.logger.info "DISCOVERED PUBSUB LEAF: #{jid}, #{node}" if node.eql?(AgentXmpp.pubsub_root) or node.eql?(AgentXmpp.user_pubsub_root) Xmpp::IqDiscoItems.get(pipe, jid, node) else Boot.call_if_implemented(:call_discovered_pubsub_node, jid, node) end end |
.on_discovery_of_pupsub_service(pipe, jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 462 def on_discovery_of_pupsub_service(pipe, jid) AgentXmpp.logger.info "DISCOVERED PUBSUB SERVICE: #{jid}" req = [Xmpp::IqPubSub.subscriptions(pipe, jid.to_s)] if /#{AgentXmpp.jid.domain}/.match(jid.to_s) add_publish_methods(pipe, jid) add_publish_method(pipe, jid) add_create_pubsub_node(pipe, jid) @pubsub_service = jid req += [Xmpp::IqDiscoItems.get(pipe, jid.to_s)] + init_remote_services(pipe) end; req end |
.on_discovery_of_user_pubsub_root(pipe, pubsub, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
491 492 493 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 491 def on_discovery_of_user_pubsub_root(pipe, pubsub, node) AgentXmpp.logger.info "DISCOVERED USER PUBSUB ROOT: #{pubsub.to_s}, #{node}" end |
.on_message_chat(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. process chat messages .….….….….….….….….….….….….….….….….….….….….….….….….….….
35 36 37 38 39 40 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 35 def (pipe, stanza) params = {:xmlns => 'message:chat', :to => stanza.from.to_s, :from => stanza.from.to_s, :id => stanza.id, :body => stanza.body} AgentXmpp.logger.info "RECEIVED CHAT MESSAGE FROM: #{stanza.from.to_s}" Controller.new(pipe, params).invoke_chat end |
.on_message_headline(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. process headline messages .….….….….….….….….….….….….….….….….….….….….….….….….….….
57 58 59 60 61 62 63 64 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 57 def (pipe, stanza) AgentXmpp.logger.info "RECEIVED HEADLINE MESSAGE FROM: #{stanza.from.to_s}" if event = stanza.event on_pubsub_event(pipe, event, stanza.to.to_s, stanza.from.to_s) else (pipe, stanza) end end |
.on_message_normal(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. process normal messages .….….….….….….….….….….….….….….….….….….….….….….….….….….
45 46 47 48 49 50 51 52 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 45 def (pipe, stanza) AgentXmpp.logger.info "RECEIVED NORMAL MESSAGE FROM: #{stanza.from.to_s}" if event = stanza.event on_pubsub_event(pipe, event, stanza.to.to_s, stanza.from.to_s) else (pipe, stanza) end end |
.on_postauthenticate_features(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
150 151 152 153 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 150 def on_postauthenticate_features(pipe) AgentXmpp.logger.info "SESSION STARTED" Xmpp::Iq.bind(pipe) if pipe.stream_features.has_key?('bind') end |
.on_preauthenticate_features(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
133 134 135 136 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 133 def on_preauthenticate_features(pipe) AgentXmpp.logger.info "SESSION INITIALIZED" Xmpp::SASL.authenticate(pipe.stream_mechanisms) end |
.on_presence(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. presence .….….….….….….….….….….….….….….….….….….….….….….….….….….
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 167 def on_presence(pipe, presence) from_jid = presence.from if Contact.has_jid?(presence.from) or AgentXmpp.is_account_jid?(from_jid) Roster.update(presence) AgentXmpp.logger.info "RECEIVED PRESENCE FROM: #{from_jid.to_s}" response = [] unless from_jid.to_s.eql?(AgentXmpp.jid.to_s) Boot.call_if_implemented(:call_received_presence, from_jid.to_s, :available) response << Xmpp::IqVersion.get(pipe, from_jid) unless Roster.has_version?(from_jid) unless Service.has_jid?(from_jid) response << Xmpp::IqDiscoInfo.get(pipe, from_jid) response << Xmpp::IqDiscoItems.get(pipe, from_jid, 'http://jabber.org/protocol/commands') end end; response else AgentXmpp.logger.warn "RECEIVED PRESENCE FROM JID NOT IN ROSTER: #{from_jid}" unless from_jid.to_s.eql?(AgentXmpp.jid.to_s) end end |
.on_presence_error(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
228 229 230 231 232 233 234 235 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 228 def on_presence_error(pipe, presence) from_jid = presence.from AgentXmpp.logger.warn "RECEIVED PRESENCE ERROR FROM: #{presence.from.to_s}" if Contact.has_jid?(presence.from) or AgentXmpp.is_account_jid?(from_jid) AgentXmpp.logger.warn "REMOVING '#{presence.from.to_s}' FROM ROSTER" Xmpp::IqRoster.remove(pipe, from_jid.to_s) end end |
.on_presence_subscribe(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
187 188 189 190 191 192 193 194 195 196 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 187 def on_presence_subscribe(pipe, presence) from_jid = presence.from.to_s if Contact.has_jid?(presence.from) AgentXmpp.logger.info "RECEIVED SUBSCRIBE REQUEST: #{from_jid}" Xmpp::Presence.accept(from_jid) else AgentXmpp.logger.warn "RECEIVED SUBSCRIBE REQUEST FROM JID NOT IN ROSTER: #{from_jid}" Xmpp::Presence.decline(from_jid) end end |
.on_presence_subscribed(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
199 200 201 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 199 def on_presence_subscribed(pipe, presence) AgentXmpp.logger.info "SUBSCRIPTION ACCEPTED: #{presence.from.to_s}" end |
.on_presence_unavailable(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
204 205 206 207 208 209 210 211 212 213 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 204 def on_presence_unavailable(pipe, presence) from_jid = presence.from if Contact.has_jid?(from_jid) or AgentXmpp.is_account_jid?(from_jid) Roster.update(presence) Boot.call_if_implemented(:call_received_presence, from_jid.to_s, :unavailable) AgentXmpp.logger.info "RECEIVED UNAVAILABLE PRESENCE FROM: #{from_jid.to_s }" else AgentXmpp.logger.warn "RECEIVED UNAVAILABLE PRESENCE FROM JID NOT IN ROSTER: #{from_jid}" end end |
.on_presence_unsubscribed(pipe, presence) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
216 217 218 219 220 221 222 223 224 225 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 216 def on_presence_unsubscribed(pipe, presence) from_jid = presence.from if Contact.has_jid?(from_jid) Contact.destroy_by_jid(from_jid) AgentXmpp.logger.info "RECEIVED UNSUBSCRIBED REQUEST: #{from_jid.to_s}" Xmpp::IqRoster.remove(pipe, from_jid) else AgentXmpp.logger.warn "RECEIVED UNSUBSCRIBED REQUEST FROM JID NOT IN ROSTER: #{from_jid.to_s}" end end |
.on_publish_error(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
457 458 459 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 457 def on_publish_error(pipe, result, node) AgentXmpp.logger.info "ERROR PUBLISING TO NODE: #{node}, #{result.from.to_s}" end |
.on_publish_result(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. pubsub .….….….….….….….….….….….….….….….….….….….….….….….….….….
452 453 454 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 452 def on_publish_result(pipe, result, node) AgentXmpp.logger.info "PUBLISH TO NODE ACKNOWLEDEGED: #{node}, #{result.from.to_s}" end |
.on_pubsub_affiliations_error(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
531 532 533 534 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 531 def on_pubsub_affiliations_error(pipe, result) from_jid = result.from AgentXmpp.logger.info "RECEIVED ERROR ON AFFILIATIONS REQUEST FROM: #{from_jid}" end |
.on_pubsub_affiliations_result(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
525 526 527 528 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 525 def on_pubsub_affiliations_result(pipe, result) from_jid = result.from AgentXmpp.logger.info "RECEIVED AFFILIATIONS FROM: #{from_jid}" end |
.on_pubsub_create_node_error(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
548 549 550 551 552 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 548 def on_pubsub_create_node_error(pipe, result, node) from_jid = result.from Publication.update_status(node, :error) AgentXmpp.logger.info "RECEIVED CREATE NODE ERROR FROM: #{from_jid.to_s}, #{node}" end |
.on_pubsub_create_node_result(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
537 538 539 540 541 542 543 544 545 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 537 def on_pubsub_create_node_result(pipe, result, node) from_jid = result.from Publication.update_status(node, :active) Boot.call_if_implemented(:call_discovered_pubsub_node, from_jid, node) AgentXmpp.logger.info "RECEIVED CREATE NODE RESULT FROM: #{from_jid.to_s}, #{node}" if node.eql?(AgentXmpp.user_pubsub_root) [on_discovery_of_user_pubsub_root(pipe, from_jid, node), Xmpp::IqDiscoInfo.get(pipe, from_jid.to_s, node)] end end |
.on_pubsub_delete_node_error(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
561 562 563 564 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 561 def on_pubsub_delete_node_error(pipe, result, node) from_jid = result.from AgentXmpp.logger.info "RECEIVED DELETE NODE ERROR FROM: #{from_jid.to_s}, #{node}" end |
.on_pubsub_delete_node_result(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
555 556 557 558 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 555 def on_pubsub_delete_node_result(pipe, result, node) from_jid = result.from AgentXmpp.logger.info "RECEIVED DELETE NODE RESULT FROM: #{from_jid.to_s}, #{node}" end |
.on_pubsub_event(pipe, event, to, from) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. process events .….….….….….….….….….….….….….….….….….….….….….….….….….….
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 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 69 def on_pubsub_event(pipe, event, to, from) AgentXmpp.logger.info "RECEIVED EVENT FROM: #{from.to_s}" event.items.each do |is| src = is.node.split('/') src_jid = "#{src[3]}@#{src[2]}" is.item.each do |i| if Message.update_received_event_item(i, from, is.node) params = { :xmlns => 'http://jabber.org/protocol/pubsub#event', :to => to, :pubsub => from, :node => is.node, :from => src_jid, :id => i.id, :resources => Roster.find_all_by_contact_jid_and_status(Xmpp::Jid.new(src_jid), :available)} if data = i.x and data.type.eql?(:result) params.update(:data => data.to_native) Controller.new(pipe, params).invoke_event elsif entry = i.entry params.update(:data => entry.title) Controller.new(pipe, params).invoke_event else (pipe, event) end else (pipe, event) end end end end |
.on_pubsub_subscribe_error(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
574 575 576 577 578 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 574 def on_pubsub_subscribe_error(pipe, result, node) from_jid = result.from AgentXmpp.logger.warn "RECEIVED SUBSCRIBE ERROR FROM: #{from_jid.to_s}, #{node}" on_pubsub_subscribe_error_item_not_found(pipe, result, node) if result.error.error.eql?('item-not-found') end |
.on_pubsub_subscribe_error_item_not_found(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
581 582 583 584 585 586 587 588 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 581 def on_pubsub_subscribe_error_item_not_found(pipe, result, node) from_jid = result.from AgentXmpp.logger.warn "RECEIVED SUBSCRIBE ERROR ITEM-NOT-FOUND FROM: #{from_jid.to_s}, #{node}; " + "RETRYING SUBSCRIPTION IN #{AgentXmpp::SUBSCRIBE_RETRY_PERIOD}s" EventMachine::Timer.new(AgentXmpp::SUBSCRIBE_RETRY_PERIOD) do pipe.send_resp(Xmpp::IqPubSub.subscribe(pipe, from_jid.to_s, node)) end end |
.on_pubsub_subscribe_result(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
567 568 569 570 571 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 567 def on_pubsub_subscribe_result(pipe, result, node) from_jid = result.from.to_s Subscription.update(result, node, from_jid) AgentXmpp.logger.info "RECEIVED SUBSCRIBE RESULT FROM: #{from_jid}, #{node}" end |
.on_pubsub_subscriptions_error(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
519 520 521 522 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 519 def on_pubsub_subscriptions_error(pipe, result) from_jid = result.from AgentXmpp.logger.warn "RECEIVED ERROR ON SUBSCRIPTION REQUEST FROM: #{from_jid}" end |
.on_pubsub_subscriptions_result(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 496 def on_pubsub_subscriptions_result(pipe, result) from_jid = result.from.to_s AgentXmpp.logger.info "RECEIVED SUBSCRIPTIONS FROM: #{from_jid}" app_subs = BaseController.subscriptions(result.from.domain) srvr_subs = result.pubsub.subscriptions.map do |s| AgentXmpp.logger.info "SUBSCRIBED TO NODE: #{from_jid}, #{s.node}" Subscription.update(s, s.node, from_jid); s.node end reqs = app_subs.inject([]) do |r,s| unless srvr_subs.include?(s) AgentXmpp.logger.info "SUBSCRIBING TO NODE: #{from_jid}, #{s}" r << Xmpp::IqPubSub.subscribe(pipe, from_jid, s) end; r end srvr_subs.inject(reqs) do |r,s| unless app_subs.include?(s) AgentXmpp.logger.warn "UNSUBSCRIBING FROM NODE: #{from_jid}, #{s}" r << Xmpp::IqPubSub.unsubscribe(pipe, from_jid, s) end; r end end |
.on_pubsub_unsubscribe_error(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
598 599 600 601 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 598 def on_pubsub_unsubscribe_error(pipe, result, node) from_jid = result.from AgentXmpp.logger.info "RECEIVED UNSUBSCRIBE ERROR FROM: #{from_jid.to_s}, #{node}" end |
.on_pubsub_unsubscribe_result(pipe, result, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
591 592 593 594 595 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 591 def on_pubsub_unsubscribe_result(pipe, result, node) from_jid = result.from Subscription.destroy_by_node(node) AgentXmpp.logger.info "RECEIVED UNSUBSCRIBE RESULT FROM: #{from_jid.to_s}, #{node}" end |
.on_remove_roster_item(pipe, roster_item) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
279 280 281 282 283 284 285 286 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 279 def on_remove_roster_item(pipe, roster_item) AgentXmpp.logger.info "REMOVE ROSTER ITEM" roster_item_jid = roster_item.jid if Contact.has_jid?(roster_item_jid) AgentXmpp.logger.info "REMOVED ROSTER ITEM: #{roster_item_jid.to_s}" Contact.destroy_by_jid(roster_item_jid) end end |
.on_remove_roster_item_error(pipe, roster_item_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
313 314 315 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 313 def on_remove_roster_item_error(pipe, roster_item_jid) AgentXmpp.logger.info "REMOVE ROSTER ITEM RECEIVED ERROR REMOVING: #{roster_item_jid}" end |
.on_remove_roster_item_result(pipe, roster_item_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
308 309 310 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 308 def on_remove_roster_item_result(pipe, roster_item_jid) AgentXmpp.logger.info "REMOVE ROSTER ITEM ACKNOWLEDEGED FROM: #{roster_item_jid}" end |
.on_roster_item(pipe, roster_item) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 250 def on_roster_item(pipe, roster_item) roster_item_jid = roster_item.jid AgentXmpp.logger.info "RECEIVED ROSTER ITEM: #{roster_item_jid.to_s}" if Contact.has_jid?(roster_item_jid) case roster_item.subscription when :none if roster_item.ask.eql?(:subscribe) AgentXmpp.logger.info "CONTACT SUBSCRIPTION PENDING: #{roster_item_jid.to_s}" roster_item.subscription = :ask else AgentXmpp.logger.info "CONTACT ADDED TO ROSTER: #{roster_item_jid.to_s}" roster_item.subscription = :added end when :to AgentXmpp.logger.info "SUBSCRIBED TO CONTACT PRESENCE: #{roster_item_jid.to_s}" when :from AgentXmpp.logger.info "CONTACT SUBSCRIBED TO PRESENCE: #{roster_item_jid.to_s}" when :both AgentXmpp.logger.info "CONTACT SUBSCRIPTION BIDIRECTIONAL: #{roster_item_jid.to_s}" end Contact.update_with_roster_item(roster_item) check_roster_item_group(pipe, roster_item) else AgentXmpp.logger.info "REMOVING ROSTER ITEM: #{roster_item_jid.to_s}" Xmpp::IqRoster.remove(pipe, roster_item_jid) end end |
.on_roster_result(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. roster management .….….….….….….….….….….….….….….….….….….….….….….….….….….
240 241 242 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 240 def on_roster_result(pipe, stanza) process_roster_items(pipe, stanza) end |
.on_roster_set(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
245 246 247 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 245 def on_roster_set(pipe, stanza) process_roster_items(pipe, stanza) end |
.on_start_session(pipe) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
156 157 158 159 160 161 162 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 156 def on_start_session(pipe) AgentXmpp.logger.info "SESSION STARTED" add_send_command_request_method(pipe) add_send_chat_method(pipe) [Send(Xmpp::Presence.new(nil, nil, AgentXmpp.priority)), Xmpp::IqRoster.get(pipe), Xmpp::IqDiscoInfo.get(pipe, AgentXmpp.jid.domain)] end |
.on_unsupported_message(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. errors .….….….….….….….….….….….….….….….….….….….….….….….….….….
99 100 101 102 103 104 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 99 def (pipe, stanza) AgentXmpp.logger.info "RECEIVED UNSUPPORTED MESSAGE: #{stanza.to_s}" if stanza.class.eql?(AgentXmpp::Xmpp::Iq) Xmpp::ErrorResponse.feature_not_implemented(stanza) end end |
.on_update_roster_item_error(pipe, roster_item_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
303 304 305 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 303 def on_update_roster_item_error(pipe, roster_item_jid) AgentXmpp.logger.info "UPDATE ROSTER ITEM RECEIVED ERROR REMOVING: #{roster_item_jid}" end |
.on_update_roster_item_result(pipe, roster_item_jid) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
298 299 300 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 298 def on_update_roster_item_result(pipe, roster_item_jid) AgentXmpp.logger.info "UPDATE ROSTER ITEM ACKNOWLEDEGED FROM: #{roster_item_jid}" end |
.on_version_error(pipe, result) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
339 340 341 342 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 339 def on_version_error(pipe, result) from_jid = result.from AgentXmpp.logger.warn "RECEIVED VERSION ERROR FROM: #{from_jid.to_s}" end |
.on_version_get(pipe, request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
327 328 329 330 331 332 333 334 335 336 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 327 def on_version_get(pipe, request) from_jid = request.from if Contact.has_jid?(from_jid) or AgentXmpp.is_account_jid?(from_jid) AgentXmpp.logger.info "RECEIVED VERSION REQUEST: #{request.from.to_s}" Xmpp::IqVersion.result(pipe, request) else AgentXmpp.logger.warn "RECEIVED VERSION REQUEST FROM JID NOT IN ROSTER: #{request.from.to_s}" Xmpp::ErrorResponse.service_unavailable(request) end end |
.on_version_result(pipe, version) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….…. service discovery management .….….….….….….….….….….….….….….….….….….….….….….….….….….
320 321 322 323 324 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 320 def on_version_result(pipe, version) from_jid, query = version.from, version.query AgentXmpp.logger.info "RECEIVED VERSION RESULT: #{from_jid.to_s}, #{query.iname}, #{query.version}" Roster.update(query, from_jid) end |
.process_pubsub_discoinfo(type, pipe, from, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
616 617 618 619 620 621 622 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 616 def process_pubsub_discoinfo(type, pipe, from, node) case type when 'service' then pipe.broadcast_to_delegates(:on_discovery_of_pupsub_service, pipe, from) when 'collection' then pipe.broadcast_to_delegates(:on_discovery_of_pupsub_collection, pipe, from, node) when 'leaf' then pipe.broadcast_to_delegates(:on_discovery_of_pupsub_leaf, pipe, from, node) end end |
.process_roster_items(pipe, stanza) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
625 626 627 628 629 630 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 625 def process_roster_items(pipe, stanza) [stanza.query.inject([]) do |r, i| method = i.subscription.eql?(:remove) ? :on_remove_roster_item : :on_roster_item r.push(pipe.broadcast_to_delegates(method, pipe, i)) end, pipe.broadcast_to_delegates(:on_all_roster_items, pipe)].smash end |
.update_publish_nodes(pipe, pubsub, items) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 |
# File 'lib/agent_xmpp/client/message_delegate.rb', line 708 def update_publish_nodes(pipe, pubsub, items) disco_nodes = items.map{|i| i.node} config_nodes = Publication.find_all.map{|pub| "#{AgentXmpp.user_pubsub_root}/#{pub[:node]}"} updates = disco_nodes.inject([]) do |u,n| unless config_nodes.include?(n) AgentXmpp.logger.warn "DELETING PUBSUB NODE: #{pubsub.to_s}, #{n}" u << Xmpp::IqPubSubOwner.delete_node(pipe, pubsub.to_s, n) end; u end config_nodes.inject(updates) do |u,n| unless disco_nodes.include?(n) AgentXmpp.logger.info "ADDING PUBSUB NODE: #{pubsub.to_s}, #{n}" u << Xmpp::IqPubSub.create_node(pipe, pubsub.to_s, n) end; u end end |