bin/punchblock-console in punchblock-0.5.1 vs bin/punchblock-console in punchblock-0.6.0

- old
+ new

@@ -5,16 +5,24 @@ require 'punchblock' require 'pry' require 'logger' require 'optparse' +puts <<-DEPRECATION +******************** +WARNING: This utility is deprecated and will be removed from a future version of Punchblock without further notice. You should use the punchblock-console gem instead. +******************** +DEPRECATION + include Punchblock Thread.abort_on_exception = true options = { :username => 'usera@127.0.0.1', :password => '1', :wire_log_file => 'log/rayo-wire.log', :transport_log_file => 'log/rayo-transport.log', :auto_reconnect => false } +connection_class = Connection::XMPP + option_parser = OptionParser.new do |opts| opts.banner = "Usage: punchblock-console [-u usera@127.0.0.1] [-p abc123]" opts.on("-u", "--username USERNAME", String, "Specify the XMPP JID to connect to") do |u| options[:username] = u end @@ -28,10 +36,15 @@ options[:wire_log_file] = wlf end opts.on("--transport-log-file log/transportlog.log", String, "Specify the file to which the transport log should be written") do |tlf| options[:transport_log_file] = tlf end + opts.on("--asterisk", "Use Asterisk") do |tlf| + connection_class = Connection::Asterisk + options[:host] = '127.0.0.1' + options[:port] = 5038 + end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("-v", "--version", "Show version") do @@ -51,12 +64,13 @@ options[:wire_logger].level = Logger::DEBUG options[:wire_logger].debug "Starting up..." options[:transport_logger] = Logger.new options.delete(:transport_log_file) options[:transport_logger].level = Logger::DEBUG options[:transport_logger].debug "Starting up..." +options[:logger] = options[:wire_logger] -connection = Connection::XMPP.new options +connection = connection_class.new options client = Client.new :connection => connection [:INT, :TERM].each do |signal| trap signal do puts "Shutting down!" @@ -83,9 +97,13 @@ loop do event = client.event_queue.pop if event == Connection::Connected puts event puts "Waiting for a call..." + next + end + unless event.call_id + puts "Ad-hoc event: #{event.inspect}" next end puts "#{event.class} event for call: #{event.call_id}" case event when Event::Offer