Sha256: 7c15da191b59cde90a3577a16a5a1aa240ce43e00004725e7ab5e37f8e79df9b

Contents?: true

Size: 849 Bytes

Versions: 13

Compression:

Stored size: 849 Bytes

Contents

module Blather
class Stream

  # @private
  class Component < Stream
    NAMESPACE = 'jabber:component:accept'

    def receive(node) # :nodoc:
      if node.element_name == 'handshake'
        ready!
      else
        super
      end

      if node.document.find_first('/stream:stream[not(stream:error)]', :xmlns => NAMESPACE, :stream => STREAM_NS)
        send "<handshake>#{Digest::SHA1.hexdigest(node['id']+@password)}</handshake>"
      end
    end

    def send(stanza)
      stanza.from ||= self.jid if stanza.respond_to?(:from) && stanza.respond_to?(:from=)
      super stanza
    end

    def start
      @parser = Parser.new self
      send "<stream:stream to='#{@jid}' xmlns='#{NAMESPACE}' xmlns:stream='#{STREAM_NS}'>"
    end

    def cleanup
      @parser.finish if @parser
      super
    end
  end #Client

end #Stream
end #Blather

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
blather-2.0.0 lib/blather/stream/component.rb
blather-1.2.0 lib/blather/stream/component.rb
blather-1.1.4 lib/blather/stream/component.rb
blather-1.1.3 lib/blather/stream/component.rb
blather-1.1.2 lib/blather/stream/component.rb
blather-1.1.1 lib/blather/stream/component.rb
blather-1.1.0 lib/blather/stream/component.rb
blather-1.0.0 lib/blather/stream/component.rb
blather-0.8.8 lib/blather/stream/component.rb
blather-0.8.7 lib/blather/stream/component.rb
blather-0.8.6 lib/blather/stream/component.rb
blather-0.8.5 lib/blather/stream/component.rb
blather-0.8.4 lib/blather/stream/component.rb