Class: Jabber::Bytestreams::IqQueryBytestreams

Inherits:
IqQuery show all
Defined in:
lib/xmpp4r/bytestreams/iq/bytestreams.rb

Overview

Class for accessing <query/> elements with xmlns='jabber.org/protocol/bytestreams' in <iq/> stanzas.

Constant Summary collapse

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

Instance Method Summary collapse

Methods inherited from IqQuery

add_namespaceclass, import

Methods inherited from REXML::Element

#delete_elements, #first_element, #first_element_text, #import, import, #replace_element_text

Constructor Details

#initialize(sid = nil, mode = nil) ⇒ IqQueryBytestreams

Initialize such a <query/>

sid
String

Session-ID

mode
Symbol

:tcp or :udp



18
19
20
21
22
23
# File 'lib/xmpp4r/bytestreams/iq/bytestreams.rb', line 18

def initialize(sid=nil, mode=nil)
  super()
  add_namespace(IqQueryBytestreams::NS_BYTESTREAMS)
  self.sid = sid
  self.mode = mode
end

Instance Method Details

#activateObject

Get the text of the <activate/> child

result
JID

or [nil]



77
78
79
80
# File 'lib/xmpp4r/bytestreams/iq/bytestreams.rb', line 77

def activate
  j = first_element_text('activate')
  j ? JID.new(j) : nil
end

#activate=(s) ⇒ Object

Set the text of the <activate/> child

s
JID


85
86
87
# File 'lib/xmpp4r/bytestreams/iq/bytestreams.rb', line 85

def activate=(s)
  replace_element_text('activate', s ? s.to_s : nil)
end

#modeObject

Transfer mode

result

:tcp or :udp



50
51
52
53
54
55
# File 'lib/xmpp4r/bytestreams/iq/bytestreams.rb', line 50

def mode
  case attributes['mode']
    when 'udp' then :udp
    else :tcp
  end
end

#mode=(m) ⇒ Object

Set the transfer mode

m

:tcp or :udp



60
61
62
63
64
65
# File 'lib/xmpp4r/bytestreams/iq/bytestreams.rb', line 60

def mode=(m)
  case m
    when :udp then attributes['mode'] = 'udp'
    else attributes['mode'] = 'tcp'
  end
end

#sidObject

Session-ID



37
38
39
# File 'lib/xmpp4r/bytestreams/iq/bytestreams.rb', line 37

def sid
  attributes['sid']
end

#sid=(s) ⇒ Object

Set Session-ID



43
44
45
# File 'lib/xmpp4r/bytestreams/iq/bytestreams.rb', line 43

def sid=(s)
  attributes['sid'] = s
end

#streamhost_usedObject

Get the <streamhost-used/> child

result
StreamHostUsed


70
71
72
# File 'lib/xmpp4r/bytestreams/iq/bytestreams.rb', line 70

def streamhost_used
  first_element('streamhost-used')
end

#typed_add(xe) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/xmpp4r/bytestreams/iq/bytestreams.rb', line 25

def typed_add(xe)
  if xe.kind_of?(REXML::Element) and xe.name == 'streamhost'
    super StreamHost.new.import(xe)
  elsif xe.kind_of?(REXML::Element) and xe.name == 'streamhost-used'
    super StreamHostUsed.new.import(xe)
  else
    super xe
  end
end