Sha256: 5aae4317cccee63c4f42d0add23746406935fcab1b28812a6d092012ba2bc7c2

Contents?: true

Size: 694 Bytes

Versions: 3

Compression:

Stored size: 694 Bytes

Contents

module Blather # :nodoc:
module Stream # :nodoc:

  class TLS # :nodoc:
    def initialize(stream)
      @stream = stream
      @callbacks = {
        'starttls'  => proc { @stream.send "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>" },
        'proceed'   => proc { @stream.start_tls; @callbacks['success'].call },
        'success'   => proc { },
        'failure'   => proc { }
      }
    end

    def success(&callback)
      @callbacks['success'] = callback
    end

    def failure(&callback)
      @callbacks['failure'] = callback
    end

    def receive(node)
      @callbacks[node.element_name].call if @callbacks[node.element_name]
    end
  end #TLS

end #Stream
end #Blather

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blather-0.1 lib/blather/core/stream/tls.rb
blather-0.2.1 lib/blather/stream/tls.rb
blather-0.2 lib/blather/stream/tls.rb