Class: Jabber::Bytestreams::IBBTarget
- Defined in:
- lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb
Overview
Implementation of IBB at the target side
Constant Summary
Constants inherited from IBB
Jabber::Bytestreams::IBB::NS_IBB
Instance Attribute Summary collapse
-
#block_size ⇒ Object
readonly
You may read the block-size after accept.
Instance Method Summary collapse
-
#accept ⇒ Object
Wait for the initiator side to start the stream.
-
#initialize(stream, session_id, initiator_jid, target_jid) ⇒ IBBTarget
constructor
A new instance of IBBTarget.
Methods inherited from IBB
#active?, #close, #flush, #read, #write
Constructor Details
#initialize(stream, session_id, initiator_jid, target_jid) ⇒ IBBTarget
Returns a new instance of IBBTarget.
13 14 15 16 |
# File 'lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb', line 13 def initialize(stream, session_id, initiator_jid, target_jid) # Target and Initiator are swapped here, because we're the target super(stream, session_id, target_jid, initiator_jid) end |
Instance Attribute Details
#block_size ⇒ Object (readonly)
You may read the block-size after accept
11 12 13 |
# File 'lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb', line 11 def block_size @block_size end |
Instance Method Details
#accept ⇒ Object
Wait for the initiator side to start the stream.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb', line 21 def accept connect_sem = Semaphore.new @stream.add_iq_callback(200, self) { |iq| open = iq.first_element('open') if iq.type == :set and iq.from == @peer_jid and iq.to == @my_jid and open and open.attributes['sid'] == @session_id @stream.delete_iq_callback(self) activate @block_size = (open.attributes['block-size'] || 4096).to_i reply = iq.answer(false) reply.type = :result @stream.send(reply) connect_sem.run true else false end } connect_sem.wait true end |