Class Jabber::Version::Responder
In: lib/xmpp4r/version/helper/responder.rb
Parent: Object
XMLStanza Message Presence Iq REXML::Element X IqQuery Error StreamHost IqSiFileRange IqSiFile StreamHostUsed IqSi XRosterItem RosterItem IqFeature XMUCUserItem XMUCUserInvite Feature Identity Item XDataField XDataReported XDataTitle XDataInstructions IqVcard Singleton IdGenerator Connection Client Component Comparable JID RuntimeError ErrorException AuthenticationFailure SOCKS5Error Stream SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IqQuery IqQueryBytestreams IqQueryVersion IqQueryRoster IqQueryDiscoItems IqQueryDiscoInfo IBB IBBTarget IBBInitiator Responder SimpleResponder X XRoster XMUCUser XMUC XDelay XData MUCClient SimpleMUCClient Base DigestMD5 Plain FileSource StreamParser SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Helper MUCBrowser Helper Helper lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/connection.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/xmlstanza.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/stream.rb lib/xmpp4r/client.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/x.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/query.rb lib/xmpp4r/message.rb lib/xmpp4r/presence.rb lib/xmpp4r/bytestreams/helper/ibb/initiator.rb lib/xmpp4r/bytestreams/iq/si.rb lib/xmpp4r/bytestreams/iq/bytestreams.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb lib/xmpp4r/bytestreams/helper/ibb/base.rb lib/xmpp4r/bytestreams/helper/ibb/target.rb Bytestreams lib/xmpp4r/version/iq/version.rb lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb Version lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb lib/xmpp4r/roster/x/roster.rb Roster lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/muc/x/muc.rb lib/xmpp4r/muc/helper/mucclient.rb lib/xmpp4r/muc/x/mucuseritem.rb lib/xmpp4r/muc/helper/mucbrowser.rb lib/xmpp4r/muc/x/mucuserinvite.rb lib/xmpp4r/muc/helper/simplemucclient.rb MUC lib/xmpp4r/sasl.rb SASL lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber Module: Jabber

A class to answer version requests using IqQueryVersion

If you don’t need the flexibility of dynamic responses with the callback you can register with add_version_callback, take a look at SimpleResponder

Methods

Public Class methods

Initialize a new version responder

Registers it’s callback (prio = 180, ref = self)

stream:[Stream] Where to register callback handlers

[Source]

    # File lib/xmpp4r/version/helper/responder.rb, line 22
22:       def initialize(stream)
23:         @stream = stream
24:         @versioncbs = CallbackList.new
25: 
26:         stream.add_iq_callback(180, self) { |iq|
27:           iq_callback(iq)
28:         }
29:       end

Public Instance methods

Add a callback for Iq stanzas with IqQueryVersion

First argument passed to block is the Iq stanza, second argument is a block, which can be called with software name, version and os

Example:

  my_version_helper.add_version_callback { |iq,block|
    block.call('Cool client', '6.0', 'Cool OS')
  }

[Source]

    # File lib/xmpp4r/version/helper/responder.rb, line 42
42:       def add_version_callback(priority = 0, ref = nil, &block)
43:         @versioncbs.add(priority, ref, block)
44:       end

<iq/> callback handler to answer Software Version queries (registered by constructor and used internally only)

Used internally

[Source]

    # File lib/xmpp4r/version/helper/responder.rb, line 51
51:       def iq_callback(iq)
52:         if iq.type == :get
53:           if iq.query.kind_of?(IqQueryVersion)
54:             replyblock = lambda { |name,version,os|
55:               answer = iq.answer
56:               answer.type = :result
57:               answer.query.set_iname(name).set_version(version).set_os(os)
58: 
59:               @stream.send(answer)
60:             }
61:             @versioncbs.process(iq, replyblock)
62:           else
63:             false
64:           end
65:         else
66:           false
67:         end
68:       end

[Validate]