asterisk-ari-client 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ari/client.rb +22 -26
- data/lib/asterisk/ari/client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fc8fd04e5ce4dda1088d1ce10f1b0e277ccd658
|
4
|
+
data.tar.gz: fc2881cb4c2bd69bfc1887d96ed4c987237ed0a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b50e0b96d66452077838c9c0fa4023f89d119da7f9ce728518c0a0aaa8d0dc0c8fe962fc2bd7a3b3fbdf452f73d030f6552291211c1c0aa3dc226fbfbd2029a
|
7
|
+
data.tar.gz: 0f9dd78084a4ec64e530c97003a0708c65d9fc490bff0ec368705b85c44c958e6ac1c1a98e74bedcf6acaf0d422a859993700fd5ea8210adbcc051c8ea6ee4c0
|
data/lib/ari/client.rb
CHANGED
@@ -63,34 +63,30 @@ module Ari
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def handle_websocket_message(event)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
if event_model_ids.include? instance.id
|
85
|
-
emit "#{event_name}-#{instance.id}", handler
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
self.emit event_name, handler_klass.new(object.merge(client: self))
|
90
|
-
rescue => err
|
91
|
-
emit :websocket_error, err
|
66
|
+
handle_websocket_close(event) and return if event.type == :close
|
67
|
+
return unless event.type == :text
|
68
|
+
|
69
|
+
object = MultiJson.load event.data
|
70
|
+
|
71
|
+
handler_klass = Ari.const_get object['type'] rescue nil
|
72
|
+
return unless handler_klass
|
73
|
+
event_name = object['type'].gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
|
74
|
+
|
75
|
+
instances = self.class.instance_listeners[event_name.to_sym]
|
76
|
+
|
77
|
+
event_properties = (handler_klass.instance_methods - Ari::Event.instance_methods)
|
78
|
+
event_properties.reject! { |p| p.to_s.end_with? '=' }
|
79
|
+
handler = handler_klass.new(object.merge(client: self))
|
80
|
+
event_model_ids = event_properties.map { |p| handler.send(p).id rescue nil }.compact
|
81
|
+
[*instances].each do |instance|
|
82
|
+
if event_model_ids.include? instance.id
|
83
|
+
Thread.new { emit "#{event_name}-#{instance.id}", handler }
|
92
84
|
end
|
93
85
|
end
|
86
|
+
|
87
|
+
Thread.new { self.emit event_name, handler_klass.new(object.merge(client: self)) }
|
88
|
+
rescue => err
|
89
|
+
emit :websocket_error, err
|
94
90
|
end
|
95
91
|
|
96
92
|
def handle_websocket_error(err)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asterisk-ari-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Svoboda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
261
|
version: '0'
|
262
262
|
requirements: []
|
263
263
|
rubyforge_project:
|
264
|
-
rubygems_version: 2.4.
|
264
|
+
rubygems_version: 2.4.8
|
265
265
|
signing_key:
|
266
266
|
specification_version: 4
|
267
267
|
summary: Ruby client library for the Asterisk REST Interface (ARI).
|