class Blather::Stanza::Iq::Si

# Si Stanza

[XEP-0096: SI File Transfer](xmpp.org/extensions/xep-0096.html)

This is a base class for any si based Iq stanzas. It provides a base set of methods for working with si stanzas

@example Basic file transfer acceptance

client.register_handler :file_transfer do |iq|
  transfer = Blather::FileTransfer.new(client, iq)
  transfer.accept(Blather::FileTransfer::SimpleFileReceiver, "/path/to/#{iq.si.file["name"]}", iq.si.file["size"].to_i)
end

@example Basic file transfer refusal

client.register_handler :file_transfer do |iq|
  transfer = Blather::FileTransfer.new(client, iq)
  transfer.decline
end

@example File transfer acceptance by in-band bytestreams with custom handler

client.register_handler :file_transfer do |iq|
  transfer = Blather::FileTransfer.new(client, iq)
  transfer.allow_ibb = true
  transfer.allow_s5b = false
  transfer.accept(MyFileReceiver, iq)
end

@handler :file_transfer

Constants

NS_SI

@private

Public Class Methods

new(type = :set) click to toggle source

Overrides the parent method to ensure a si node is created

@see Blather::Stanza::Iq.new

Calls superclass method Blather::Stanza::Iq::new
# File lib/blather/stanza/iq/si.rb, line 43
def self.new(type = :set)
  node = super
  node.si
  node
end

Public Instance Methods

inherit(node) click to toggle source

Overrides the parent method to ensure the current si node is destroyed

@see Blather::Stanza::Iq#inherit

Calls superclass method
# File lib/blather/stanza/iq/si.rb, line 52
def inherit(node)
  si.remove
  super
end
reply() click to toggle source

Overrides the parent method to ensure the current si node is destroyed

@see Blather::Stanza#reply

Calls superclass method Blather::Stanza#reply
# File lib/blather/stanza/iq/si.rb, line 78
def reply
  reply = Stanza::Iq::Si.import super
  reply.si.remove
  reply
end
si() click to toggle source

Find or create si node

@return [Si::Si]

# File lib/blather/stanza/iq/si.rb, line 60
def si
  Si.find_or_create self
end
si=(node) click to toggle source

Replaces si node

@param [Si::Si, XML::Node] node the stanza's new si node

@return [Si::Si]

# File lib/blather/stanza/iq/si.rb, line 69
def si=(node)
  si.remove
  self << node
  Si.find_or_create self
end