adhearsion 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 0.8.6
2
+ - Fix packaging problem so all files are publicly readable
3
+ - Improve AMI reconnecting logic; add "connection refused" retry timer
4
+ - AGI protocol improvements: parse the status code and response text
5
+
1
6
  0.8.5
2
7
  - Added XMPP module and sample component. This allows you to easily write components which utilise a persistent XMPP connection maintained by Adhearsion
3
8
  - Prefer finding the dialplan.rb entry point by the AGI request URI instead of the calling context
@@ -117,7 +117,7 @@ ADHEARSION_FILES = %w{
117
117
 
118
118
  Gem::Specification.new do |s|
119
119
  s.name = "adhearsion"
120
- s.version = "0.8.5"
120
+ s.version = Adhearsion::VERSION::STRING
121
121
 
122
122
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
123
123
  s.authors = ["Jay Phillips", "Jason Goecke", "Ben Klang"]
@@ -129,7 +129,7 @@ Gem::Specification.new do |s|
129
129
 
130
130
  s.files = ADHEARSION_FILES
131
131
 
132
- s.has_rdoc = false
132
+ s.has_rdoc = true
133
133
  s.homepage = "http://adhearsion.com"
134
134
  s.require_paths = ["lib"]
135
135
  s.rubyforge_project = "adhearsion"
@@ -144,6 +144,7 @@ class EventSocket
144
144
  def connection_dropped!
145
145
  @state_lock.synchronize do
146
146
  unless @state.equal? :connection_dropped
147
+ @socket.close rescue nil
147
148
  @state = :connection_dropped
148
149
  @handler.disconnected
149
150
  end
@@ -151,7 +151,7 @@ module Adhearsion
151
151
  load_components
152
152
  init_events_file
153
153
 
154
- ahn_log "Adhearsion initialized!"
154
+ ahn_log "Adhearsion v#{Adhearsion::VERSION::STRING} initialized!"
155
155
  Adhearsion.status = :running
156
156
 
157
157
  trigger_after_initialized_hooks
@@ -129,8 +129,8 @@ module Adhearsion
129
129
  end
130
130
 
131
131
  def initialize(overrides = {})
132
- @listening_port = overrides.has_key?(:port) ? overrides[:port] : self.class.default_listening_port
133
- @listening_host = overrides.has_key?(:host) ? overrides[:host] : self.class.default_listening_host
132
+ @listening_port = overrides.has_key?(:port) ? overrides.delete(:port) : self.class.default_listening_port
133
+ @listening_host = overrides.has_key?(:host) ? overrides.delete(:host) : self.class.default_listening_host
134
134
  super
135
135
  end
136
136
  end
@@ -2,7 +2,7 @@ module Adhearsion #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0 unless defined? MAJOR
4
4
  MINOR = 8 unless defined? MINOR
5
- TINY = 5 unless defined? TINY
5
+ TINY = 6 unless defined? TINY
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.') unless defined? STRING
8
8
  end
@@ -51,12 +51,33 @@ module Adhearsion
51
51
  # Utility method to read from pbx. Hangup if nil.
52
52
  def read
53
53
  returning from_pbx.gets do |message|
54
- ahn_log.agi.debug "<<< #{message}"
55
54
  # AGI has many conditions that might indicate a hangup
56
55
  raise Hangup if message.nil?
57
- raise Hangup if message.match(/^HANGUP\n?$/i)
58
- raise Hangup if message.match(/^HANGUP\s?\d{3}/i)
59
- raise Hangup if message.match(/^511 Command Not Permitted on a dead channel/i)
56
+
57
+ ahn_log.agi.debug "<<< #{message}"
58
+
59
+ code, rest = *message.split(' ', 2)
60
+
61
+ if code == "511"
62
+ # '511' Command Not Permitted on a dead channel
63
+ ahn_log.agi.debug "AGI 500 error. Raising hangup"
64
+ raise Hangup
65
+ end
66
+
67
+ if (500..599) === code.to_i
68
+ # 500 AGI protocol error. Catches (at least):
69
+ # 520 Invalid command syntax.
70
+ # 510 Invalid or unknown command
71
+ # If we have hit this then something bad has happened.
72
+ ahn_log.agi.warn "AGI 500 error encountered. This may be a bug in Adhearsion. Please report it at http://adhearsion.lighthouseapp.com"
73
+ end
74
+
75
+ # If the message starts with HANGUP it's a silly 1.6 OOB message
76
+ case message
77
+ when /^HANGUP/, /^HANGUP\n?$/i, /^HANGUP\s?\d{3}/i
78
+ ahn_log.agi.debug "AGI HANGUP. Raising hangup"
79
+ raise Hangup
80
+ end
60
81
  end
61
82
  end
62
83
 
@@ -203,7 +224,7 @@ module Adhearsion
203
224
  format = filename.slice!(/\.[^\.]+$/)
204
225
  if (format.nil?)
205
226
  ahn_log.agi.warn "Format not specified and not detected. Defaulting to \"gsm\""
206
- format = gsm
227
+ format = "gsm"
207
228
  end
208
229
  format.sub!(/^\./, "")
209
230
  else
@@ -33,6 +33,8 @@ module Adhearsion
33
33
  dahdishowchannels coreshowchannels dbget
34
34
  status konferencelist] unless defined? CAUSAL_EVENT_NAMES
35
35
 
36
+ RETRY_SLEEP = 5
37
+
36
38
  class << self
37
39
 
38
40
  def connect(*args)
@@ -262,11 +264,11 @@ module Adhearsion
262
264
  def clear_actions_connection
263
265
  stop_actions_writer_loop
264
266
  clear_actions_connection_resources
265
- disconnect_actions_connection
267
+ disconnect_actions_connection if @actions_state.equal? :connected
266
268
  end
267
269
 
268
270
  def clear_events_connection
269
- disconnect_events_connection
271
+ disconnect_events_connection if @events_state.equal? :connected
270
272
  end
271
273
 
272
274
  def disconnect!
@@ -543,6 +545,10 @@ module Adhearsion
543
545
  handler.disconnected { actions_connection_disconnected }
544
546
  end
545
547
  login_actions
548
+ rescue Errno::ECONNREFUSED => e
549
+ ahn_log.ami.warn "ACTIONS thread connection refused! Retrying in #{RETRY_SLEEP} seconds..."
550
+ sleep RETRY_SLEEP
551
+ retry
546
552
  end
547
553
 
548
554
  def disconnect_actions_connection
@@ -569,6 +575,10 @@ module Adhearsion
569
575
  end
570
576
  login_events
571
577
  ahn_log.ami "Successful AMI events-only connection into #{@username}@#{@host}"
578
+ rescue Errno::ECONNREFUSED => e
579
+ ahn_log.ami.warn "EVENTS thread connection refused! Retrying in #{RETRY_SLEEP} seconds..."
580
+ sleep RETRY_SLEEP
581
+ retry
572
582
  end
573
583
 
574
584
  def login_actions
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adhearsion
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
4
+ hash: 51
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 5
10
- version: 0.8.5
9
+ - 6
10
+ version: 0.8.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jay Phillips
@@ -193,7 +193,7 @@ files:
193
193
  - lib/theatre/version.rb
194
194
  - LICENSE
195
195
  - Rakefile
196
- has_rdoc: false
196
+ has_rdoc: true
197
197
  homepage: http://adhearsion.com
198
198
  licenses: []
199
199