Sha256: 00059f5542f67ee157ab6f57597eca32a5460e3515d37c88425eaf00b146b278

Contents?: true

Size: 1.29 KB

Versions: 20

Compression:

Stored size: 1.29 KB

Contents

# =XMPP4R - XMPP Library for Ruby
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
# Website::http://home.gna.org/xmpp4r/

module Jabber
  module Bytestreams
    ##
    # Implementation of IBB at the target side
    class IBBTarget < IBB
      # You may read the block-size after accept
      attr_reader :block_size

      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

      ##
      # Wait for the initiator side to start
      # the stream.
      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
    end
  end
end

Version data entries

20 entries across 20 versions & 8 rubygems

Version Path
bryanl-xmpp4r-0.3.2 lib/xmpp4r/bytestreams/helper/ibb/target.rb
edavey-xmpp4r-0.4.1 lib/xmpp4r/bytestreams/helper/ibb/target.rb
edavey-xmpp4r-0.4.2 lib/xmpp4r/bytestreams/helper/ibb/target.rb
edavey-xmpp4r-0.4 lib/xmpp4r/bytestreams/helper/ibb/target.rb
heipei-xmpp4r-0.3.2 lib/xmpp4r/bytestreams/helper/ibb/target.rb
mojodna-xmpp4r-0.4.0.2 lib/xmpp4r/bytestreams/helper/ibb/target.rb
mojodna-xmpp4r-0.4.0.3 lib/xmpp4r/bytestreams/helper/ibb/target.rb
cerberus-0.8.0 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb
cerberus-0.7.9 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb
edavis10-cerberus-0.7.8 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb
cerberus-0.7.8 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb
cerberus-0.7.7 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb
cerberus-0.7.6 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb
cerberus-0.7.2 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb
cerberus-0.7.5 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb
cerberus-0.7 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/ibb/target.rb
mack-notifier-0.8.2 lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/ibb/target.rb
mack-notifier-0.8.3.1 lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/ibb/target.rb
mack-notifier-0.8.3 lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/ibb/target.rb
xmpp4r-0.4 lib/xmpp4r/bytestreams/helper/ibb/target.rb