Sha256: 1c2f98e58a7d93fb1b3cb9f3f89b03c7d0b02d080d95a271faf30805fac881a5
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
# encoding: UTF-8 module Vines class Stanza class Iq < Stanza register "/iq" VALID_TYPES = %w[get set result error].freeze VALID_TYPES.each do |type| define_method "#{type}?" do self['type'] == type end end def process if self['id'] && VALID_TYPES.include?(self['type']) route_iq or raise StanzaErrors::FeatureNotImplemented.new(@node, 'cancel') else raise StanzaErrors::BadRequest.new(@node, 'modify') end end def to_result doc = Document.new doc.create_element('iq', 'from' => stream.domain, 'id' => self['id'], 'to' => stream.user.jid.to_s, 'type' => 'result') end private def route_iq to = validate_to return false if to.nil? || to.to_s == stream.domain self['from'] = stream.user.jid.to_s if local? stream.available_resources(to).each do |recipient| recipient.write(@node) end else route end true end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vines-0.3.2 | lib/vines/stanza/iq.rb |
vines-0.3.1 | lib/vines/stanza/iq.rb |
vines-0.3.0 | lib/vines/stanza/iq.rb |