Class Jabber::Bytestreams::IBBTarget
In: lib/xmpp4r/bytestreams/helper/ibb/target.rb
Parent: IBB

Implementation of IBB at the target side

Methods

accept   accept_wait   new  

Attributes

block_size  [R]  You may read the block-size after accept

Public Class methods

[Source]

    # File lib/xmpp4r/bytestreams/helper/ibb/target.rb, line 13
13:       def initialize(stream, session_id, initiator_jid, target_jid)
14:         # Target and Initiator are swapped here, because we're the target
15:         super(stream, session_id, target_jid, initiator_jid)
16:         @accept_ready = Semaphore::new
17:       end

Public Instance methods

Wait for the initiator side to start the stream.

[Source]

    # File lib/xmpp4r/bytestreams/helper/ibb/target.rb, line 26
26:       def accept
27:         connect_sem = Semaphore.new
28: 
29:         @stream.add_iq_callback(200, self) { |iq|
30:           open = iq.first_element('open')
31:           if iq.type == :set and iq.from == @peer_jid and iq.to == @my_jid and open and open.attributes['sid'] == @session_id
32:             @stream.delete_iq_callback(self)
33:             activate
34:             @block_size = (open.attributes['block-size'] || 4096).to_i
35: 
36:             reply = iq.answer(false)
37:             reply.type = :result
38:             @stream.send(reply)
39: 
40:             connect_sem.run
41:             true
42:           else
43:             false
44:           end
45:         }
46: 
47:         @accept_ready.run
48: 
49:         connect_sem.wait
50:         true
51:       end

[Source]

    # File lib/xmpp4r/bytestreams/helper/ibb/target.rb, line 19
19:       def accept_wait
20:         @accept_ready.wait
21:       end

[Validate]