Class: Jabber::Command::Responder

Class | Jabber::Command::Responder
In: | lib/xmpp4r/command/helper/responder.rb
Parent: | Object

The Responder Helper handles the low-level stuff of the Ad-hoc commands (JEP 0050).

### Methods

add_commands_disco_callback add_commands_exec_callback iq_callback new

### Public Class methods

new(stream)

Initialize a Responder

[Source]

        # File lib/xmpp4r/command/helper/responder.rb, line 12
    12:       def initialize(stream)
    13:         @stream = stream
    14:         @commandsdiscocbs = CallbackList.new
    15:         @commandexeccbs = CallbackList.new
    16:
    17:         stream.add_iq_callback(180, self) { |iq|
    18:           iq_callback(iq)
    19:         }
    20:       end

### Public Instance methods

add_commands_disco_callback(priority = 0, ref = nil, &block)

Add a callback for <query> stanzas asking for the list of ad-hoc commands

[Source]

        # File lib/xmpp4r/command/helper/responder.rb, line 25
    25:       def add_commands_disco_callback(priority = 0, ref = nil, &block)
    26:         @commandsdiscocbs.add(priority, ref, block)
    27:       end

add_commands_exec_callback(priority = 0, ref = nil, &block)

Add a callback for <command> stanzas asking for the execution of an ad-hoc command

[Source]

        # File lib/xmpp4r/command/helper/responder.rb, line 32
    32:       def add_commands_exec_callback(priority = 0, ref = nil, &block)
    33:         @commandexeccbs.add(priority, ref, block)
    34:       end

iq_callback(iq)

Handles <iq> stanzas and execute callbacks

[Source]

        # File lib/xmpp4r/command/helper/responder.rb, line 38
    38:       def iq_callback(iq)
    39:         if iq.type == :get
    40:           if iq.query.kind_of?(Jabber::Discovery::IqQueryDiscoItems) &&
    41:              iq.query.node == "http://jabber.org/protocol/commands"
    42:             @commandsdiscocbs.process(iq)
    43:           end
    44:         elsif iq.type == :set && iq.command
    45:           @commandexeccbs.process(iq)
    46:         end
    47:       end

[Validate]