| Class | Jabber::Bytestreams::SOCKS5BytestreamsTarget |
| In: |
lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb
|
| Parent: | SOCKS5Bytestreams |
SOCKS5 Bytestreams implementation of the target site
Wait until the stream has been established
May raise various exceptions
# File lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb, line 14
14: def accept
15: error = nil
16: connect_sem = Semaphore.new
17:
18: @stream.add_iq_callback(200, self) { |iq|
19: if iq.type == :set and iq.from == @initiator_jid and iq.to == @target_jid and iq.query.kind_of?(IqQueryBytestreams)
20: begin
21: @stream.delete_iq_callback(self)
22:
23: iq.query.each_element('streamhost') { |streamhost|
24: if streamhost.host and streamhost.port and not @socks
25: begin
26: @socks = connect_socks(streamhost)
27: @streamhost_used = streamhost
28: rescue Exception => e
29: Jabber::debuglog("SOCKS5 Bytestreams: #{e.class}: #{e}\n#{e.backtrace.join("\n")}")
30: @streamhost_cbs.process(streamhost, :failure, e)
31: end
32: end
33: }
34:
35: reply = iq.answer(false)
36: if @streamhost_used
37: reply.type = :result
38: reply.add(IqQueryBytestreams.new)
39: reply.query.add(StreamHostUsed.new(@streamhost_used.jid))
40: else
41: reply.type = :error
42: reply.add(Error.new('item-not-found'))
43: end
44: @stream.send(reply)
45: rescue Exception => e
46: error = e
47: end
48:
49: connect_sem.run
50: true
51: else
52: false
53: end
54: }
55:
56: connect_sem.wait
57: raise error if error
58: (@socks != nil)
59: end