Class: Blather::Stanza::Iq::S5b

Inherits:
Query show all
Defined in:
lib/blather/stanza/iq/s5b.rb

Overview

# SOCKS5 Bytestreams Stanza

[XEP-0065: SOCKS5 Bytestreams](xmpp.org/extensions/xep-0065.html)

Defined Under Namespace

Classes: StreamHost, StreamHostUsed

Constant Summary

NS_S5B =
'http://jabber.org/protocol/bytestreams'

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

Instance Method Summary collapse

Methods inherited from Query

#inherit, new, #query

Methods inherited from Blather::Stanza::Iq

#error?, #get?, import, new, #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, new, parse, register, #to_stanza

Constructor Details

This class inherits a constructor from Blather::Stanza

Instance Method Details

#replyObject

Overrides the parent method to remove query node



18
19
20
21
22
# File 'lib/blather/stanza/iq/s5b.rb', line 18

def reply
  reply = super
  reply.remove_children :query
  reply
end

#sidString

Get the sid of the file transfer

Returns:

  • (String)


27
28
29
# File 'lib/blather/stanza/iq/s5b.rb', line 27

def sid
  query['sid']
end

#streamhost_usedS5b::StreamHostUsed

Get the used streamhost

Returns:



34
35
36
# File 'lib/blather/stanza/iq/s5b.rb', line 34

def streamhost_used
  StreamHostUsed.new query.find_first('.//ns:streamhost-used', :ns => self.class.registered_ns)
end

#streamhost_used=(jid) ⇒ Object

Set the used streamhost

Parameters:

  • jid (Blather::JID, String, nil)

    the jid of the used streamhost



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

def streamhost_used=(jid)
  query.find('.//ns:streamhost-used', :ns => self.class.registered_ns).remove

  if jid
    query << StreamHostUsed.new(jid)
  end
end

#streamhostsArray<S5b::StreamHost>

Get the streamhosts

Returns:



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

def streamhosts
  query.find('.//ns:streamhost', :ns => self.class.registered_ns).map do |s|
    StreamHost.new s
  end
end

#streamhosts=(streamhosts) ⇒ Object

Set the streamhosts

Parameters:

  • streamhosts

    the array of streamhosts, passed directly to StreamHost.new



61
62
63
64
65
66
# File 'lib/blather/stanza/iq/s5b.rb', line 61

def streamhosts=(streamhosts)
  query.find('.//ns:streamhost', :ns => self.class.registered_ns).remove
  if streamhosts
    [streamhosts].flatten.each { |s| self.query << StreamHost.new(s) }
  end
end