Class: Blather::Stanza::Iq::Si

Inherits:
Blather::Stanza::Iq show all
Defined in:
lib/blather/stanza/iq/si.rb

Overview

# 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

Examples:

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

Basic file transfer refusal

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

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

Defined Under Namespace

Classes: Si

Constant Summary collapse

NS_SI =
'http://jabber.org/protocol/si'

Constants inherited from Blather::Stanza::Iq

VALID_TYPES

Constants inherited from XMPPNode

XMPPNode::BASE_NAMES

Instance Attribute Summary

Attributes inherited from Blather::Stanza

#handler_hierarchy

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Blather::Stanza::Iq

#error?, #get?, import, #reply!, #result?, #set?, #type=

Methods inherited from Blather::Stanza

#as_error, #error?, #from, #from=, handler_list, #id, #id=, #initialize, next_id, register, #reply!, #to, #to=, #type, #type=

Methods inherited from XMPPNode

class_from_registration, #decorate, decorator_modules, import, parse, register, #to_stanza

Constructor Details

This class inherits a constructor from Blather::Stanza

Class Method Details

.new(type = :set) ⇒ Object

Overrides the parent method to ensure a si node is created



43
44
45
46
47
# File 'lib/blather/stanza/iq/si.rb', line 43

def self.new(type = :set)
  node = super
  node.si
  node
end

Instance Method Details

#inherit(node) ⇒ Object

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

See Also:

  • Blather::Stanza::Iq#inherit


52
53
54
55
# File 'lib/blather/stanza/iq/si.rb', line 52

def inherit(node)
  si.remove
  super
end

#replyObject

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



78
79
80
81
82
# File 'lib/blather/stanza/iq/si.rb', line 78

def reply
  reply = Stanza::Iq::Si.import super
  reply.si.remove
  reply
end

#siSi::Si

Find or create si node

Returns:



60
61
62
# File 'lib/blather/stanza/iq/si.rb', line 60

def si
  Si.find_or_create self
end

#si=(node) ⇒ Si::Si

Replaces si node

Parameters:

  • node (Si::Si, XML::Node)

    the stanza’s new si node

Returns:



69
70
71
72
73
# File 'lib/blather/stanza/iq/si.rb', line 69

def si=(node)
  si.remove
  self << node
  Si.find_or_create self
end