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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ced2496e519a26e6291bb719686a52645aad490
4
- data.tar.gz: 2b0c8f8f38e6394ec90499079dfeb6321b470ebb
3
+ metadata.gz: 7fc8fd04e5ce4dda1088d1ce10f1b0e277ccd658
4
+ data.tar.gz: fc2881cb4c2bd69bfc1887d96ed4c987237ed0a3
5
5
  SHA512:
6
- metadata.gz: 2f8f6d269307b5d89289d9760352e975005ff7044cbc48befae9868b6875b48e7f82cef0dc97407358fccf4e2eafde7fd94f0a032514eec5c8712e4e4c561c1e
7
- data.tar.gz: fdf3eb413dffb79596790731a993b4908ab4afa8105527e4fac9b601ee87844ac22ffacbfabae2ea03cf790d14ffd1c7a23ce9384b7a488ec409c2f8a5cfd423
6
+ metadata.gz: 6b50e0b96d66452077838c9c0fa4023f89d119da7f9ce728518c0a0aaa8d0dc0c8fe962fc2bd7a3b3fbdf452f73d030f6552291211c1c0aa3dc226fbfbd2029a
7
+ data.tar.gz: 0f9dd78084a4ec64e530c97003a0708c65d9fc490bff0ec368705b85c44c958e6ac1c1a98e74bedcf6acaf0d422a859993700fd5ea8210adbcc051c8ea6ee4c0
@@ -63,34 +63,30 @@ module Ari
63
63
  end
64
64
 
65
65
  def handle_websocket_message(event)
66
- Thread.new do
67
- begin
68
- handle_websocket_close(event) and next if event.type == :close
69
- next unless event.type == :text
70
-
71
- object = MultiJson.load event.data
72
-
73
- handler_klass = Ari.const_get object['type'] rescue nil
74
- next unless handler_klass
75
- event_name = object['type'].gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
76
-
77
- instances = self.class.instance_listeners[event_name.to_sym]
78
-
79
- event_properties = (handler_klass.instance_methods - Ari::Event.instance_methods)
80
- event_properties.reject! { |p| p.to_s.end_with? '=' }
81
- handler = handler_klass.new(object.merge(client: self))
82
- event_model_ids = event_properties.map { |p| handler.send(p).id rescue nil }.compact
83
- [*instances].each do |instance|
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)
@@ -1,7 +1,7 @@
1
1
  module Asterisk
2
2
  module Ari
3
3
  module Client
4
- VERSION = "0.0.6"
4
+ VERSION = "0.0.7"
5
5
  end
6
6
  end
7
7
  end
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.6
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-06-06 00:00:00.000000000 Z
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.6
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).