Method: Klomp::Connection#initialize
- Defined in:
- lib/klomp/connection.rb
#initialize(server, options = {}) ⇒ Connection
Returns a new instance of Connection.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/klomp/connection.rb', line 10 def initialize(server, ={}) @options = if server =~ /^stomp:\/\// uri = URI.parse server host, port = uri.host, uri.port @options['login'] = uri.user if uri.user @options['passcode'] = uri.password if uri.password if uri.query && !uri.query.empty? uri.query.split('&').each {|pair| k, v = pair.split('=', 2); @options[k] = v } end else address = server.split ':' port, host = address.pop.to_i, address.pop @options['host'] ||= address.pop unless address.empty? end @options['server'] = [host, port] @options['host'] ||= host @subscriptions = {} @logger = ['logger'] @select_timeout = ['select_timeout'] || 0.5 connect end |