Sha256: 7fc3eb8648d1f42f1a706a7c7983258ba360b18bb0c17db9cc7a6fd2432a66b6

Contents?: true

Size: 888 Bytes

Versions: 24

Compression:

Stored size: 888 Bytes

Contents

module Blather
class Stream

  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
      start_stream = <<-STREAM
        <stream:stream
          to='#{@jid}'
          xmlns='#{NAMESPACE}'
          xmlns:stream='#{STREAM_NS}'
        >
      STREAM
      send start_stream.gsub(/\s+/, ' ')
    end
  end #Client

end #Stream
end #Blather

Version data entries

24 entries across 24 versions & 3 rubygems

Version Path
sprsquish-blather-0.4.0 lib/blather/stream/component.rb
sprsquish-blather-0.4.1 lib/blather/stream/component.rb
sprsquish-blather-0.4.2 lib/blather/stream/component.rb
sprsquish-blather-0.4.3 lib/blather/stream/component.rb
sprsquish-blather-0.4.4 lib/blather/stream/component.rb
blather-0.4.16 lib/blather/stream/component.rb
blather-0.4.15 lib/blather/stream/component.rb
shingara-blather-0.4.14 lib/blather/stream/component.rb
blather-0.4.14 lib/blather/stream/component.rb
blather-0.4.13 lib/blather/stream/component.rb
blather-0.4.12 lib/blather/stream/component.rb
blather-0.4.11 lib/blather/stream/component.rb
blather-0.4.10 lib/blather/stream/component.rb
shingara-blather-0.4.9 lib/blather/stream/component.rb
shingara-blather-0.4.8 lib/blather/stream/component.rb
blather-0.4.8 lib/blather/stream/component.rb
blather-0.4.7 lib/blather/stream/component.rb
blather-0.4.6 lib/blather/stream/component.rb
blather-0.4.5 lib/blather/stream/component.rb
blather-0.4.4 lib/blather/stream/component.rb