Sha256: d442896927d04a5aa16cbb2782608712c4a1f7eb29e98be919b8f50bbacd6f6f

Contents?: true

Size: 748 Bytes

Versions: 1

Compression:

Stored size: 748 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
      send "<stream:stream to='#{@jid}' xmlns='#{NAMESPACE}' xmlns:stream='#{STREAM_NS}'>"
    end
  end #Client

end #Stream
end #Blather

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blather-0.8.2 lib/blather/stream/component.rb