Sha256: 8eac05966a4784e60665bc85e7429ea4db83a7eafd614e76d82f322adb2d42d6

Contents?: true

Size: 941 Bytes

Versions: 1

Compression:

Stored size: 941 Bytes

Contents

module Blather
class Stream

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

    def receive(node) # :nodoc:
      if @state == :started
        super
      else
        if node.element_name == 'handshake'
          ready!
        elsif 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
    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

1 entries across 1 versions & 1 rubygems

Version Path
tp-blather-0.8.5 lib/blather/stream/component.rb