Sha256: 973cbc62a8977809f3c35f7f4210e218e3840870ce37b29f43d2930c302cc20a

Contents?: true

Size: 901 Bytes

Versions: 18

Compression:

Stored size: 901 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
      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

18 entries across 18 versions & 1 rubygems

Version Path
blather-0.8.1 lib/blather/stream/component.rb
blather-0.8.0 lib/blather/stream/component.rb
blather-0.7.1 lib/blather/stream/component.rb
blather-0.7.0 lib/blather/stream/component.rb
blather-0.6.2 lib/blather/stream/component.rb
blather-0.6.1 lib/blather/stream/component.rb
blather-0.6.0 lib/blather/stream/component.rb
blather-0.5.12 lib/blather/stream/component.rb
blather-0.5.11 lib/blather/stream/component.rb
blather-0.5.10 lib/blather/stream/component.rb
blather-0.5.9 lib/blather/stream/component.rb
blather-0.5.8 lib/blather/stream/component.rb
blather-0.5.7 lib/blather/stream/component.rb
blather-0.5.6 lib/blather/stream/component.rb
blather-0.5.4 lib/blather/stream/component.rb
blather-0.5.3 lib/blather/stream/component.rb
blather-0.5.2 lib/blather/stream/component.rb
blather-0.5.0 lib/blather/stream/component.rb