Class | Jabber::Helpers::Version |
In: |
lib/xmpp4r/helpers/version.rb
|
Parent: | Object |
A class to answer version requests using IqQueryVersion
This is simplification as one doesn’t need dynamic version answering normally.
Example usage:
Jabber::Helpers::Version.new(my_client, "My cool XMPP4R script", "1.0", "Younicks")
name | [RW] | |
os | [RW] | |
version | [RW] |
Initialize a new version responder
Registers it’s callback (prio = 180, ref = "Helpers::Version")
stream: | [Stream] Where to register callback handlers |
name: | [String] Software name for answers |
version: | [String] Software versio for answers |
os: | [String] Optional operating system name for answers |
# File lib/xmpp4r/helpers/version.rb, line 31 31: def initialize(stream, name, version, os=nil) 32: @stream = stream 33: 34: @name = name 35: @version = version 36: @os = os 37: 38: stream.add_iq_callback(180, "Helpers::Version") { |iq| 39: iq_callback(iq) 40: } 41: end
<iq/> callback handler to answer Software Version queries (registered by constructor and used internally only)
Used internally
# File lib/xmpp4r/helpers/version.rb, line 48 48: def iq_callback(iq) 49: if iq.type == :get 50: if iq.query.kind_of?(IqQueryVersion) 51: iq.from, iq.to = iq.to, iq.from 52: iq.type = :result 53: iq.query.set_iname(@name).set_version(@version).set_os(@os) 54: 55: @stream.send(iq) 56: 57: true 58: end 59: end 60: end