punchblock 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/CHANGELOG.md +34 -21
- data/Rakefile +20 -0
- data/lib/punchblock/client/component_registry.rb +2 -0
- data/lib/punchblock/client.rb +2 -2
- data/lib/punchblock/command/accept.rb +2 -0
- data/lib/punchblock/command/answer.rb +2 -0
- data/lib/punchblock/command/dial.rb +2 -0
- data/lib/punchblock/command/hangup.rb +2 -0
- data/lib/punchblock/command/join.rb +2 -0
- data/lib/punchblock/command/mute.rb +2 -0
- data/lib/punchblock/command/redirect.rb +2 -0
- data/lib/punchblock/command/reject.rb +3 -1
- data/lib/punchblock/command/unjoin.rb +2 -0
- data/lib/punchblock/command/unmute.rb +2 -0
- data/lib/punchblock/command.rb +2 -0
- data/lib/punchblock/command_node.rb +2 -0
- data/lib/punchblock/component/asterisk/agi/command.rb +4 -2
- data/lib/punchblock/component/asterisk/agi.rb +2 -0
- data/lib/punchblock/component/asterisk/ami/action.rb +4 -2
- data/lib/punchblock/component/asterisk/ami.rb +2 -0
- data/lib/punchblock/component/asterisk.rb +2 -0
- data/lib/punchblock/component/component_node.rb +2 -0
- data/lib/punchblock/component/input.rb +2 -0
- data/lib/punchblock/component/output.rb +2 -0
- data/lib/punchblock/component/record.rb +2 -0
- data/lib/punchblock/component/stop.rb +2 -0
- data/lib/punchblock/component.rb +2 -0
- data/lib/punchblock/connection/asterisk.rb +4 -1
- data/lib/punchblock/connection/connected.rb +2 -0
- data/lib/punchblock/connection/generic_connection.rb +5 -0
- data/lib/punchblock/connection/xmpp.rb +5 -6
- data/lib/punchblock/connection.rb +2 -0
- data/lib/punchblock/core_ext/blather/stanza/presence.rb +2 -0
- data/lib/punchblock/core_ext/blather/stanza.rb +2 -0
- data/lib/punchblock/core_ext/ruby.rb +1 -12
- data/lib/punchblock/disconnected_error.rb +2 -0
- data/lib/punchblock/event/answered.rb +2 -0
- data/lib/punchblock/event/asterisk/ami/event.rb +3 -1
- data/lib/punchblock/event/asterisk/ami.rb +2 -0
- data/lib/punchblock/event/asterisk.rb +2 -0
- data/lib/punchblock/event/complete.rb +3 -1
- data/lib/punchblock/event/dtmf.rb +2 -0
- data/lib/punchblock/event/end.rb +2 -0
- data/lib/punchblock/event/joined.rb +2 -0
- data/lib/punchblock/event/offer.rb +6 -0
- data/lib/punchblock/event/ringing.rb +2 -0
- data/lib/punchblock/event/unjoined.rb +2 -0
- data/lib/punchblock/event.rb +2 -0
- data/lib/punchblock/has_headers.rb +3 -1
- data/lib/punchblock/header.rb +2 -0
- data/lib/punchblock/key_value_pair_node.rb +2 -0
- data/lib/punchblock/media_container.rb +2 -0
- data/lib/punchblock/media_node.rb +2 -0
- data/lib/punchblock/protocol_error.rb +2 -0
- data/lib/punchblock/rayo_node.rb +4 -3
- data/lib/punchblock/ref.rb +2 -0
- data/lib/punchblock/translator/asterisk/call.rb +80 -26
- data/lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb +3 -1
- data/lib/punchblock/translator/asterisk/component/asterisk/ami_action.rb +3 -1
- data/lib/punchblock/translator/asterisk/component/asterisk.rb +2 -0
- data/lib/punchblock/translator/asterisk/component/input.rb +4 -2
- data/lib/punchblock/translator/asterisk/component/output.rb +21 -3
- data/lib/punchblock/translator/asterisk/component.rb +2 -0
- data/lib/punchblock/translator/asterisk.rb +50 -20
- data/lib/punchblock/translator.rb +2 -0
- data/lib/punchblock/version.rb +3 -1
- data/lib/punchblock.rb +2 -0
- data/punchblock.gemspec +2 -2
- data/spec/capture_warnings.rb +32 -0
- data/spec/punchblock/client/component_registry_spec.rb +2 -0
- data/spec/punchblock/client_spec.rb +3 -1
- data/spec/punchblock/command/accept_spec.rb +3 -1
- data/spec/punchblock/command/answer_spec.rb +3 -1
- data/spec/punchblock/command/dial_spec.rb +12 -10
- data/spec/punchblock/command/hangup_spec.rb +3 -1
- data/spec/punchblock/command/join_spec.rb +11 -9
- data/spec/punchblock/command/mute_spec.rb +3 -1
- data/spec/punchblock/command/redirect_spec.rb +5 -3
- data/spec/punchblock/command/reject_spec.rb +7 -5
- data/spec/punchblock/command/unjoin_spec.rb +7 -5
- data/spec/punchblock/command/unmute_spec.rb +3 -1
- data/spec/punchblock/command_node_spec.rb +9 -7
- data/spec/punchblock/component/asterisk/agi/command_spec.rb +21 -19
- data/spec/punchblock/component/asterisk/ami/action_spec.rb +19 -17
- data/spec/punchblock/component/component_node_spec.rb +5 -3
- data/spec/punchblock/component/input_spec.rb +51 -49
- data/spec/punchblock/component/output_spec.rb +60 -58
- data/spec/punchblock/component/record_spec.rb +36 -34
- data/spec/punchblock/connection/asterisk_spec.rb +9 -4
- data/spec/punchblock/connection/xmpp_spec.rb +40 -39
- data/spec/punchblock/event/answered_spec.rb +4 -2
- data/spec/punchblock/event/asterisk/ami/event_spec.rb +9 -7
- data/spec/punchblock/event/complete_spec.rb +12 -10
- data/spec/punchblock/event/dtmf_spec.rb +6 -4
- data/spec/punchblock/event/end_spec.rb +6 -4
- data/spec/punchblock/event/joined_spec.rb +8 -6
- data/spec/punchblock/event/offer_spec.rb +7 -5
- data/spec/punchblock/event/ringing_spec.rb +4 -2
- data/spec/punchblock/event/unjoined_spec.rb +8 -6
- data/spec/punchblock/header_spec.rb +13 -11
- data/spec/punchblock/protocol_error_spec.rb +8 -6
- data/spec/punchblock/ref_spec.rb +5 -3
- data/spec/punchblock/translator/asterisk/call_spec.rb +261 -14
- data/spec/punchblock/translator/asterisk/component/asterisk/agi_command_spec.rb +13 -11
- data/spec/punchblock/translator/asterisk/component/asterisk/ami_action_spec.rb +4 -2
- data/spec/punchblock/translator/asterisk/component/input_spec.rb +10 -8
- data/spec/punchblock/translator/asterisk/component/output_spec.rb +111 -20
- data/spec/punchblock/translator/asterisk/component_spec.rb +3 -1
- data/spec/punchblock/translator/asterisk_spec.rb +107 -10
- data/spec/spec_helper.rb +23 -17
- data/spec/support/mock_connection_with_event_handler.rb +2 -0
- metadata +43 -41
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
|
-
# develop
|
|
2
|
-
|
|
3
|
-
# v0.9.2 - 2012-
|
|
1
|
+
# [develop](https://github.com/adhearsion/punchblock)
|
|
2
|
+
|
|
3
|
+
# [v0.10.0](https://github.com/adhearsion/punchblock/compare/v0.9.2...v0.10.0) - [2012-03-19](https://rubygems.org/gems/punchblock/versions/0.10.0)
|
|
4
|
+
* Feature: app_swift is now supported on Asterisk with a media_engine type of :swift
|
|
5
|
+
* Feature: Asterisk calls now support the Join API
|
|
6
|
+
* Feature: On Asterisk, Punchblock creates a context and extension to redirect calls to
|
|
7
|
+
* Bugfix: Unjoining calls now redirects both legs
|
|
8
|
+
* Bugfix: Unlink events on Asterisk correctly send Unjoin Punchblock events
|
|
9
|
+
* Bugfix: The Asterisk translator now ignores calls to 'h' or of type 'Kill'
|
|
10
|
+
* Bugfix: Handle more XMPP connection errors gracefully
|
|
11
|
+
* Bugfix: The XMPP connection ready event is now available to external handlers
|
|
12
|
+
* Bugfix: The Asterisk connection now passes the `:media_engine` option down to the translator
|
|
13
|
+
* Bugfix: Connections now always respond to `#connected?`
|
|
14
|
+
* Bugfix: Connection termination handled gracefully on Asterisk
|
|
15
|
+
|
|
16
|
+
# [v0.9.2](https://github.com/adhearsion/punchblock/compare/v0.9.1...v0.9.2) - [2012-02-18](https://rubygems.org/gems/punchblock/versions/0.9.2)
|
|
4
17
|
* Feature: Asterisk calls receiving media commands are implicitly answered
|
|
5
18
|
* Bugfix: Unrenderable output documents on Asterisk should return a sensible error
|
|
6
19
|
* Bugfix: Log the target of commands correctly
|
|
7
20
|
* Bugfix: Do not wrap exceptions in ProtocolError
|
|
8
21
|
|
|
9
|
-
# v0.9.1 - 2012-01-30
|
|
22
|
+
# [v0.9.1](https://github.com/adhearsion/punchblock/compare/v0.9.0...v0.9.1) - [2012-01-30](https://rubygems.org/gems/punchblock/versions/0.9.1)
|
|
10
23
|
* Bugfix: Closing an disconnected XMPP connection is a no-op
|
|
11
24
|
|
|
12
|
-
# v0.9.0 - 2012-01-30
|
|
25
|
+
# [v0.9.0](https://github.com/adhearsion/punchblock/compare/v0.8.4...v0.9.0) - [2012-01-30](https://rubygems.org/gems/punchblock/versions/0.9.0)
|
|
13
26
|
* Bugfix: Remove the rest of the deprecated Tropo components (conference)
|
|
14
27
|
* Feature: Outbound dials on Asterisk now respect the dial timeout
|
|
15
28
|
* Bugfix: Registering stanza handlers on an XMPP connection now sets them in the correct order such that they do not override the internally defined handlers
|
|
16
29
|
|
|
17
|
-
# v0.8.4 - 2012-01-19
|
|
30
|
+
# [v0.8.4](https://github.com/adhearsion/punchblock/compare/v0.8.3...v0.8.4) - [2012-01-19](https://rubygems.org/gems/punchblock/versions/0.8.4)
|
|
18
31
|
* Bugfix: End, Ringing & Answered events are allowed to have headers
|
|
19
32
|
* Feature: Dial commands may have an optional timeout
|
|
20
33
|
|
|
21
|
-
# v0.8.3 - 2012-01-17
|
|
34
|
+
# [v0.8.3](https://github.com/adhearsion/punchblock/compare/v0.8.2...v0.8.3) - [2012-01-17](https://rubygems.org/gems/punchblock/versions/0.8.3)
|
|
22
35
|
* Feature: Return an error when trying to execute a command for unknown calls/components or when not understood
|
|
23
36
|
* Feature: Log calls/translator shutting down
|
|
24
37
|
* Feature: Calls and components should log their IDs
|
|
@@ -35,20 +48,20 @@
|
|
|
35
48
|
* Bugfix: A call being hung up should terminate the call actor
|
|
36
49
|
* Bugfix: Fix a mock expectation error in a test
|
|
37
50
|
|
|
38
|
-
# v0.8.2 - 2012-01-10
|
|
51
|
+
# [v0.8.2](https://github.com/adhearsion/punchblock/compare/v0.8.1...v0.8.2) - [2012-01-10](https://rubygems.org/gems/punchblock/versions/0.8.2)
|
|
39
52
|
* Feature: Support outbound dial on Asterisk
|
|
40
53
|
* Bugfix: Asterisk hangup causes should map to correct Rayo End reason
|
|
41
54
|
|
|
42
|
-
# v0.8.1 - 2012-01-09
|
|
55
|
+
# [v0.8.1](https://github.com/adhearsion/punchblock/compare/v0.8.0...v0.8.1) - [2012-01-09](https://rubygems.org/gems/punchblock/versions/0.8.1)
|
|
43
56
|
* Feature: Support DTMF Input components on Asterisk
|
|
44
57
|
|
|
45
|
-
# v0.8.0 - 2012-01-06
|
|
58
|
+
# [v0.8.0](https://github.com/adhearsion/punchblock/compare/v0.7.2...v0.8.0) - [2012-01-06](https://rubygems.org/gems/punchblock/versions/0.8.0)
|
|
46
59
|
* Feature: Expose Blather's connection timeout config when creating a Connection::XMPP
|
|
47
60
|
* Bugfix: Remove some deprecated Tropo extension components
|
|
48
61
|
* Bugfix: Remove reconnection logic since it really belongs in the consumer
|
|
49
62
|
* Feature: Raise a DisconnectedError when a disconnection is detected
|
|
50
63
|
|
|
51
|
-
# v0.7.2 - 2011-12-28
|
|
64
|
+
# [v0.7.2](https://github.com/adhearsion/punchblock/compare/v0.7.1...v0.7.2) - [2011-12-28](https://rubygems.org/gems/punchblock/versions/0.7.2)
|
|
52
65
|
* Feature: Allow sending commands to mixers easily
|
|
53
66
|
* Feature: Allow configuration of Rayo XMPP domains (root, call and mixer)
|
|
54
67
|
* Feature: Log Blather messages to the trace log level
|
|
@@ -60,12 +73,12 @@
|
|
|
60
73
|
* Bugfix: Asterisk media output should default to Asterisk native output (STREAM FILE)
|
|
61
74
|
* Bugfix: An Output node's default max_time value should be nil rather than zero
|
|
62
75
|
|
|
63
|
-
# v0.7.1 - 2011-11-24
|
|
76
|
+
# [v0.7.1](https://github.com/adhearsion/punchblock/compare/v0.7.0...v0.7.1) - [2011-11-24](https://rubygems.org/gems/punchblock/versions/0.7.1)
|
|
64
77
|
* [FEATURE] Add `Connection#not_ready!`, to instruct the server not to send any more offers.
|
|
65
78
|
* [BUGFIX] Translate all exceptions raised by the XMPP connection into a ProtocolError
|
|
66
79
|
* [UPDATE] Blather dependency to >= 0.5.9
|
|
67
80
|
|
|
68
|
-
# v0.7.0 - 2011-11-22
|
|
81
|
+
# [v0.7.0](https://github.com/adhearsion/punchblock/compare/v0.6.2...v0.7.0) - [2011-11-22](https://rubygems.org/gems/punchblock/versions/0.7.0)
|
|
69
82
|
* Bugfix: Some spec mistakes
|
|
70
83
|
* Feature: Allow execution of actions against global components on Asterisk
|
|
71
84
|
* API change: The console has been removed
|
|
@@ -74,37 +87,37 @@
|
|
|
74
87
|
* Bugfix: Bump the Celluloid dependency to avoid spec failures on JRuby and monkey-patching for mockability
|
|
75
88
|
* API change: Event handlers registered on components are no longer triggered by incoming events internally to Punchblock. These events must be consumed via a Client's event handlers or event queue and manually triggered on a component using ComponentNode#trigger_event_handler
|
|
76
89
|
|
|
77
|
-
# v0.6.2
|
|
90
|
+
# [v0.6.2](https://github.com/adhearsion/punchblock/compare/v0.6.1...v0.6.2)
|
|
78
91
|
# Feature: Added basic support for running Punchblock apps on Asterisk. Calls coming in to AsyncAGI result in the client receiving an Offer, hangup events are sent, and accept/answer/hangup commands work.
|
|
79
92
|
# API change: The logger is now set using Punchblock.logger= rather than as a hash key to Connection.new
|
|
80
93
|
|
|
81
|
-
# v0.6.1
|
|
94
|
+
# [v0.6.1](https://github.com/adhearsion/punchblock/compare/v0.6.0...v0.6.1)
|
|
82
95
|
* Feature: Allow instructing the connection we are ready. An XMPP connection will send initial presence with a status of 'chat' to the rayo domain
|
|
83
96
|
* Bugfix: When running on Asterisk, two FullyBooted events will now trigger a connected event
|
|
84
97
|
* Bugfix: No longer ignore offers from the specified rayo domain on XMPP connections
|
|
85
98
|
* Feature: Tag all event objects with the XMPP domain they came from
|
|
86
99
|
|
|
87
|
-
# v0.6.0
|
|
100
|
+
# [v0.6.0](https://github.com/adhearsion/punchblock/compare/v0.5.1...v0.6.0)
|
|
88
101
|
* API change: Punchblock consumers now need to instantiate both a Connection and a Client (see the punchblock-console gem for an example)
|
|
89
102
|
* Feature: Added a Connection for Asterisk, utilising RubyAMI to open an AMI connection to Asterisk, and allowing AMI actions to be executed. AMI events are handled by the client event handler.
|
|
90
103
|
* Deprecation: The punchblock-console and the associated DSL are now deprecated and the punchblock-console gem should be used instead
|
|
91
104
|
|
|
92
|
-
# v0.5.1
|
|
105
|
+
# [v0.5.1](https://github.com/adhearsion/punchblock/compare/v0.5.0...v0.5.1)
|
|
93
106
|
API change: Connections now raise a Punchblock::Connection::Connected instance as an event, rather than the class itself
|
|
94
107
|
|
|
95
|
-
# v0.5.0
|
|
108
|
+
# [v0.5.0](https://github.com/adhearsion/punchblock/compare/v0.4.3...v0.5.0)
|
|
96
109
|
* Refactoring/API change: Client and connection level concerns are now separated, and one must create a Connection to be passed to a Client on creation. Client now has the choice between an event queue and guarded event handlers.
|
|
97
110
|
|
|
98
|
-
# v0.4.3
|
|
111
|
+
# [v0.4.3](https://github.com/adhearsion/punchblock/compare/v0.4.2...v0.4.3)
|
|
99
112
|
* Feature: Support for meta-data on recordings (size & duration)
|
|
100
113
|
* Feature: Allow specifying all of Blather's setup options (required to use PB as an XMPP component)
|
|
101
114
|
* Bugfix: Rayo events are discarded if they don't come from the specified domain
|
|
102
115
|
* Bugfix: Component execution in the sample DSL now doesn't expect events on the main queue
|
|
103
116
|
|
|
104
|
-
# v0.4.2
|
|
117
|
+
# [v0.4.2](https://github.com/adhearsion/punchblock/compare/v0.4.1...v0.4.2)
|
|
105
118
|
* Bugfix: Conference complete event was not being handled
|
|
106
119
|
|
|
107
|
-
# v0.4.1
|
|
120
|
+
# [v0.4.1](https://github.com/adhearsion/punchblock/compare/v0.4.0...v0.4.1)
|
|
108
121
|
* Feature/API change: Components no longer have an event queue, but instead it is possible to define guarded event handlers via #register_event_handler
|
|
109
122
|
|
|
110
123
|
# v0.4.0
|
data/Rakefile
CHANGED
|
@@ -8,6 +8,7 @@ require 'ci/reporter/rake/rspec'
|
|
|
8
8
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
9
9
|
spec.pattern = 'spec/**/*_spec.rb'
|
|
10
10
|
spec.rspec_opts = '--color'
|
|
11
|
+
spec.ruby_opts = "-w -r./spec/capture_warnings"
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
task :default => :spec
|
|
@@ -16,3 +17,22 @@ task :hudson => :ci
|
|
|
16
17
|
|
|
17
18
|
require 'yard'
|
|
18
19
|
YARD::Rake::YardocTask.new
|
|
20
|
+
|
|
21
|
+
task :encodeify do
|
|
22
|
+
Dir['{lib,spec}/**/*.rb'].each do |filename|
|
|
23
|
+
File.open filename do |file|
|
|
24
|
+
first_line = file.first
|
|
25
|
+
if first_line == "# encoding: utf-8\n"
|
|
26
|
+
puts "#{filename} is utf-8"
|
|
27
|
+
else
|
|
28
|
+
puts "Making #{filename} utf-8..."
|
|
29
|
+
File.unlink filename
|
|
30
|
+
File.open filename, "w" do |new_file|
|
|
31
|
+
new_file.write "# encoding: utf-8\n\n"
|
|
32
|
+
new_file.write first_line
|
|
33
|
+
new_file.write file.read
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
data/lib/punchblock/client.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
module Punchblock
|
|
2
4
|
class Client
|
|
3
5
|
extend ActiveSupport::Autoload
|
|
@@ -24,7 +26,6 @@ module Punchblock
|
|
|
24
26
|
|
|
25
27
|
def handle_event(event)
|
|
26
28
|
event.client = self
|
|
27
|
-
pb_logger.debug "Handling event #{event} with source #{event.source}."
|
|
28
29
|
if event.source
|
|
29
30
|
event.source.add_event event
|
|
30
31
|
else
|
|
@@ -51,7 +52,6 @@ module Punchblock
|
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
def execute_command(command, options = {})
|
|
54
|
-
pb_logger.debug "Executing command: #{command.inspect} with options #{options.inspect}"
|
|
55
55
|
async = options.has_key?(:async) ? options.delete(:async) : true
|
|
56
56
|
command.client = self
|
|
57
57
|
if command.respond_to?(:register_handler)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
module Punchblock
|
|
2
4
|
module Command
|
|
3
5
|
class Reject < CommandNode
|
|
@@ -53,7 +55,7 @@ module Punchblock
|
|
|
53
55
|
if reject_reason && !VALID_REASONS.include?(reject_reason.to_sym)
|
|
54
56
|
raise ArgumentError, "Invalid Reason (#{reject_reason}), use: #{VALID_REASONS*' '}"
|
|
55
57
|
end
|
|
56
|
-
children.each
|
|
58
|
+
children.each(&:remove)
|
|
57
59
|
self << RayoNode.new(reject_reason)
|
|
58
60
|
end
|
|
59
61
|
|
data/lib/punchblock/command.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
module Punchblock
|
|
2
4
|
module Component
|
|
3
5
|
module Asterisk
|
|
@@ -23,7 +25,7 @@ module Punchblock
|
|
|
23
25
|
# @return [Array[String]] array of values of params
|
|
24
26
|
#
|
|
25
27
|
def params_array
|
|
26
|
-
params.map
|
|
28
|
+
params.map(&:value)
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
##
|
|
@@ -39,7 +41,7 @@ module Punchblock
|
|
|
39
41
|
# @param [Hash, Array] params A hash of key-value param pairs, or an array of Param objects
|
|
40
42
|
#
|
|
41
43
|
def params=(params)
|
|
42
|
-
find('//ns:param', :ns => self.class.registered_ns).each
|
|
44
|
+
find('//ns:param', :ns => self.class.registered_ns).each(&:remove)
|
|
43
45
|
[params].flatten.each { |i| self << Param.new(i) } if params.is_a? Array
|
|
44
46
|
end
|
|
45
47
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'punchblock/key_value_pair_node'
|
|
2
4
|
|
|
3
5
|
module Punchblock
|
|
@@ -44,7 +46,7 @@ module Punchblock
|
|
|
44
46
|
# @param [Hash, Array] params A hash of key-value param pairs, or an array of Param objects
|
|
45
47
|
#
|
|
46
48
|
def params=(params)
|
|
47
|
-
find('//ns:param', :ns => self.class.registered_ns).each
|
|
49
|
+
find('//ns:param', :ns => self.class.registered_ns).each(&:remove)
|
|
48
50
|
if params.is_a? Hash
|
|
49
51
|
params.each_pair { |k,v| self << Param.new(k, v) }
|
|
50
52
|
elsif params.is_a? Array
|
|
@@ -120,7 +122,7 @@ module Punchblock
|
|
|
120
122
|
# @param [Hash, Array] attributes A hash of key-value attribute pairs, or an array of Attribute objects
|
|
121
123
|
#
|
|
122
124
|
def attributes=(attributes)
|
|
123
|
-
find('//ns:attribute', :ns => self.class.registered_ns).each
|
|
125
|
+
find('//ns:attribute', :ns => self.class.registered_ns).each(&:remove)
|
|
124
126
|
if attributes.is_a? Hash
|
|
125
127
|
attributes.each_pair { |k,v| self << Attribute.new(k, v) }
|
|
126
128
|
elsif attributes.is_a? Array
|
data/lib/punchblock/component.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'ruby_ami'
|
|
2
4
|
|
|
3
5
|
module Punchblock
|
|
@@ -8,13 +10,14 @@ module Punchblock
|
|
|
8
10
|
|
|
9
11
|
def initialize(options = {})
|
|
10
12
|
@ami_client = RubyAMI::Client.new options.merge(:event_handler => lambda { |event| translator.handle_ami_event! event }, :logger => pb_logger)
|
|
11
|
-
@translator = Translator::Asterisk.new @ami_client, self
|
|
13
|
+
@translator = Translator::Asterisk.new @ami_client, self, options[:media_engine]
|
|
12
14
|
super()
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
def run
|
|
16
18
|
pb_logger.debug "Starting the RubyAMI client"
|
|
17
19
|
ami_client.start
|
|
20
|
+
raise DisconnectedError
|
|
18
21
|
end
|
|
19
22
|
|
|
20
23
|
def stop
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
%w{
|
|
2
4
|
timeout
|
|
3
5
|
blather/client/dsl
|
|
@@ -25,7 +27,7 @@ module Punchblock
|
|
|
25
27
|
def initialize(options = {})
|
|
26
28
|
raise ArgumentError unless (@username = options[:username]) && options[:password]
|
|
27
29
|
|
|
28
|
-
setup
|
|
30
|
+
setup(*[:username, :password, :host, :port, :certs, :connection_timeout].map { |key| options.delete key })
|
|
29
31
|
|
|
30
32
|
@root_domain = Blather::JID.new(options[:root_domain] || options[:rayo_domain] || @username).domain
|
|
31
33
|
@calls_domain = options[:calls_domain] || "calls.#{@root_domain}"
|
|
@@ -61,7 +63,6 @@ module Punchblock
|
|
|
61
63
|
command.mixer_name ||= options[:mixer_name]
|
|
62
64
|
command.component_id ||= options[:component_id]
|
|
63
65
|
create_iq(jid_for_command(command)).tap do |iq|
|
|
64
|
-
pb_logger.debug "Sending IQ ID #{iq.id} #{command.inspect} to #{iq.to}"
|
|
65
66
|
iq << command
|
|
66
67
|
end
|
|
67
68
|
end
|
|
@@ -76,7 +77,7 @@ module Punchblock
|
|
|
76
77
|
def connect
|
|
77
78
|
begin
|
|
78
79
|
EM.run { client.run }
|
|
79
|
-
rescue Blather::Stream::ConnectionFailed, Blather::Stream::ConnectionTimeout => e
|
|
80
|
+
rescue Blather::Stream::ConnectionFailed, Blather::Stream::ConnectionTimeout, Blather::StreamError => e
|
|
80
81
|
raise DisconnectedError.new(e.class.to_s, e.message)
|
|
81
82
|
end
|
|
82
83
|
end
|
|
@@ -125,9 +126,7 @@ module Punchblock
|
|
|
125
126
|
|
|
126
127
|
def handle_presence(p)
|
|
127
128
|
throw :pass unless p.rayo_event?
|
|
128
|
-
pb_logger.info "Receiving event for call ID #{p.call_id}"
|
|
129
129
|
@callmap[p.call_id] = p.from.domain
|
|
130
|
-
pb_logger.debug p.inspect
|
|
131
130
|
event = p.event
|
|
132
131
|
event.connection = self
|
|
133
132
|
event.domain = p.from.domain
|
|
@@ -137,7 +136,6 @@ module Punchblock
|
|
|
137
136
|
def handle_iq_result(iq, command)
|
|
138
137
|
# FIXME: Do we need to raise a warning if the domain changes?
|
|
139
138
|
@callmap[iq.from.node] = iq.from.domain
|
|
140
|
-
pb_logger.debug "Command #{iq.id} completed successfully"
|
|
141
139
|
command.response = iq.rayo_node.is_a?(Ref) ? iq.rayo_node : true
|
|
142
140
|
end
|
|
143
141
|
|
|
@@ -153,6 +151,7 @@ module Punchblock
|
|
|
153
151
|
event_handler.call Connected.new
|
|
154
152
|
pb_logger.info "Connected to XMPP as #{@username}"
|
|
155
153
|
@rayo_ping = EM::PeriodicTimer.new(@ping_period) { ping_rayo } if @ping_period
|
|
154
|
+
throw :pass
|
|
156
155
|
end
|
|
157
156
|
|
|
158
157
|
disconnected do
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
def select(&block)
|
|
3
|
-
val = super(&block)
|
|
4
|
-
if val.is_a?(Array)
|
|
5
|
-
val = val.inject({}) do |accumulator, element|
|
|
6
|
-
accumulator[element[0]] = element[1]
|
|
7
|
-
accumulator
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
val
|
|
11
|
-
end
|
|
12
|
-
end
|
|
1
|
+
# encoding: utf-8
|
|
13
2
|
|
|
14
3
|
class NullObject
|
|
15
4
|
def method_missing(*args)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'punchblock/key_value_pair_node'
|
|
2
4
|
|
|
3
5
|
module Punchblock
|
|
@@ -44,7 +46,7 @@ module Punchblock
|
|
|
44
46
|
# @param [Hash, Array] attributes A hash of key-value attribute pairs, or an array of Attribute objects
|
|
45
47
|
#
|
|
46
48
|
def attributes=(attributes)
|
|
47
|
-
find('//ns:attribute', :ns => self.class.registered_ns).each
|
|
49
|
+
find('//ns:attribute', :ns => self.class.registered_ns).each(&:remove)
|
|
48
50
|
if attributes.is_a? Hash
|
|
49
51
|
attributes.each_pair { |k,v| self << Attribute.new(k, v) }
|
|
50
52
|
elsif attributes.is_a? Array
|
data/lib/punchblock/event/end.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
module Punchblock
|
|
2
4
|
class Event
|
|
3
5
|
class Offer < Event
|
|
@@ -24,6 +26,10 @@ module Punchblock
|
|
|
24
26
|
def inspect_attributes # :nodoc:
|
|
25
27
|
[:to, :from] + super
|
|
26
28
|
end
|
|
29
|
+
|
|
30
|
+
def inspect
|
|
31
|
+
"#<Punchblock::Event::Offer to=\"#{to}\", from=\"#{from}\", call_id=\"#{call_id}\""
|
|
32
|
+
end
|
|
27
33
|
end # Offer
|
|
28
34
|
end
|
|
29
35
|
end # Punchblock
|