signalwire 2.3.3 → 2.3.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 617cfadba260ca55f6a9930c26eca415a3db201fdad4165a86f6c06955a98471
4
- data.tar.gz: e78dc8b25ac1cd28e0252962497ed620aa9794635b23b1fc72347b1458e79dfb
3
+ metadata.gz: d31f18c614ab0890b0c3000c45f607b636c8c3a3b7ad51d1e9dffae4c3b30165
4
+ data.tar.gz: 6ef1eeb8106c935d12beb8edafb67004d14c012761c43c675a9ce4d430c794d6
5
5
  SHA512:
6
- metadata.gz: 9ca9a848b357a319f84ec836fb73a75a99e5054064fbdf59ffcb44da615b0009df676da2c8abd434062747888618016220e8f016b35682808ebf3acab2a51df4
7
- data.tar.gz: f367464b5544df04e67828765a16c5368af055eb1e24328f9e8a97d93ebac5105a8ebcd840cdee984a257825e9363c49d7f5d791b636ba7e830286962374ad54
6
+ metadata.gz: 4535d5d33d7d8152ffd349d0fbeb4cb544fc71931fb72f93c2c866eda4957249ace7b5337472193ebd58f0f6a987f546a226edc97618fb8bef03652162b534db
7
+ data.tar.gz: 6887060feada342534a3b4a365eb058e93276aa50ecd8e88456d1b4495e6aee7aa47be22e26adc22dfb292e24a0291ffe3376e06b6359d27fa6d0aaffeaba457
@@ -3,7 +3,13 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
5
 
6
- ## [Unreleased]
6
+ ## [Unreleased]
7
+
8
+ ## [2.3.4] - 2020-09-09
9
+ ### Fixed
10
+ - Correctly ignore non-call events and clear handlers on call end
11
+ - Async method arguments fixed
12
+ - Fix ping race condition
7
13
 
8
14
  ## [2.3.3] - 2020-03-09
9
15
  ### Fixed
@@ -3,6 +3,7 @@
3
3
  module Signalwire
4
4
  end
5
5
 
6
+ require 'signalwire/version'
6
7
  require 'signalwire/sdk'
7
8
  require 'signalwire/logger'
8
9
  require 'signalwire/common'
@@ -4,6 +4,7 @@ require 'has_guarded_handlers'
4
4
  require 'eventmachine'
5
5
  require 'faye/websocket'
6
6
  require 'json'
7
+ require 'concurrent-ruby'
7
8
 
8
9
  module Signalwire::Blade
9
10
  class Connection
@@ -22,10 +23,14 @@ module Signalwire::Blade
22
23
  @log_traffic = options.fetch(:log_traffic, true)
23
24
  @authentication = options.fetch(:authentication, nil)
24
25
 
26
+
27
+
25
28
  @inbound_queue = EM::Queue.new
26
29
  @outbound_queue = EM::Queue.new
27
30
 
31
+ @pong = Concurrent::AtomicBoolean.new
28
32
  @keep_alive_timer = nil
33
+ @ping_is_sent = Concurrent::AtomicBoolean.new
29
34
 
30
35
  @shutdown_list = []
31
36
  end
@@ -48,6 +53,7 @@ module Signalwire::Blade
48
53
 
49
54
  def main_loop!
50
55
  EM.run do
56
+ logger.info "CREATING SOCKET"
51
57
  @ws = Faye::WebSocket::Client.new(@url)
52
58
 
53
59
  @ws.on(:open) { |event| broadcast :started, event }
@@ -71,7 +77,7 @@ module Signalwire::Blade
71
77
  begin
72
78
  @connected = true
73
79
  myreq = connect_request
74
- @pong = nil
80
+ @pong.make_false
75
81
 
76
82
  write_command(myreq) do |event|
77
83
  @session_id = event.dig(:result, :sessionid) unless @session_id
@@ -131,7 +137,9 @@ module Signalwire::Blade
131
137
  end
132
138
 
133
139
  def ping(&block)
134
- block_given? ? write_command(Ping.new, &block) : write_command(Ping.new)
140
+ ping_cmd = Ping.new
141
+ block_given? ? write_command(ping_cmd, &block) : write_command(ping_cmd)
142
+ ping_cmd
135
143
  end
136
144
 
137
145
  def subscribe(params, &block)
@@ -150,7 +158,6 @@ module Signalwire::Blade
150
158
  end
151
159
 
152
160
  def disconnect!
153
- # logger.info 'Stopping Blade event loop'
154
161
  clear_connections
155
162
  EM.stop
156
163
  end
@@ -183,19 +190,21 @@ module Signalwire::Blade
183
190
  end
184
191
 
185
192
  def keep_alive
186
- @pong = false
187
-
188
- ping do
189
- @pong = true
193
+ if @ping_is_sent.false?
194
+ ping do
195
+ @pong.make_true
196
+ end
197
+ @ping_is_sent.make_true
198
+ else
199
+ if @pong.false?
200
+ logger.error "KEEPALIVE: Ping failed"
201
+ reconnect! if connected?
202
+ end
203
+ @ping_is_sent.make_false
190
204
  end
191
205
 
192
206
  @keep_alive_timer = EventMachine::Timer.new(Signalwire::Relay::PING_TIMEOUT) do
193
- if @pong === false
194
- logger.error "Ping failed"
195
- reconnect! if connected?
196
- else
197
- keep_alive
198
- end
207
+ keep_alive
199
208
  end
200
209
  end
201
210
 
@@ -10,7 +10,8 @@ module Signalwire::Blade
10
10
  major: 2,
11
11
  minor: 1,
12
12
  revision: 0
13
- }
13
+ },
14
+ agent: "Ruby SDK/#{Signalwire::VERSION}"
14
15
  }
15
16
  }
16
17
  end
@@ -5,7 +5,7 @@ require 'forwardable'
5
5
  module Signalwire::Relay::Calling
6
6
  class ConnectAction < Action
7
7
  def result
8
- ConnectResult.new(@component)
8
+ ConnectResult.new(component: @component)
9
9
  end
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ require 'forwardable'
5
5
  module Signalwire::Relay::Calling
6
6
  class DetectAction < Action
7
7
  def result
8
- DetectResult.new(@component)
8
+ DetectResult.new(component: @component)
9
9
  end
10
10
 
11
11
  def stop
@@ -5,7 +5,7 @@ require 'forwardable'
5
5
  module Signalwire::Relay::Calling
6
6
  class FaxAction < Action
7
7
  def result
8
- FaxResult.new(@component)
8
+ FaxResult.new(component: @component)
9
9
  end
10
10
 
11
11
  def stop
@@ -5,7 +5,7 @@ require 'forwardable'
5
5
  module Signalwire::Relay::Calling
6
6
  class PlayAction < Action
7
7
  def result
8
- PlayResult.new(@component)
8
+ PlayResult.new(component: @component)
9
9
  end
10
10
 
11
11
  def stop
@@ -5,7 +5,7 @@ require 'forwardable'
5
5
  module Signalwire::Relay::Calling
6
6
  class PromptAction < Action
7
7
  def result
8
- PromptResult.new(@component)
8
+ PromptResult.new(component: @component)
9
9
  end
10
10
 
11
11
  def stop
@@ -5,7 +5,7 @@ require 'forwardable'
5
5
  module Signalwire::Relay::Calling
6
6
  class RecordAction < Action
7
7
  def result
8
- RecordResult.new(@component)
8
+ RecordResult.new(component: @component)
9
9
  end
10
10
 
11
11
  def stop
@@ -5,7 +5,7 @@ require 'forwardable'
5
5
  module Signalwire::Relay::Calling
6
6
  class SendDigitsAction < Action
7
7
  def result
8
- SendDigitsResult.new(@component)
8
+ SendDigitsResult.new(component: @component)
9
9
  end
10
10
  end
11
11
  end
@@ -7,7 +7,7 @@ module Signalwire::Relay::Calling
7
7
  def_delegators :@component, :source_device
8
8
 
9
9
  def result
10
- TapResult.new(@component)
10
+ TapResult.new(component: @component)
11
11
  end
12
12
 
13
13
  def stop
@@ -45,7 +45,7 @@ module Signalwire::Relay::Calling
45
45
  end
46
46
 
47
47
  def setup_call_event_handlers
48
- @client.on(:event, proc { |evt| call_match_event(evt) }) do |event|
48
+ @call_event_handler = @client.on(:event, proc { |evt| call_match_event(evt) }) do |event|
49
49
  case event.event_type
50
50
  when 'calling.call.connect'
51
51
  change_connect_state(event.call_params[:connect_state])
@@ -81,7 +81,8 @@ module Signalwire::Relay::Calling
81
81
  end
82
82
 
83
83
  def call_match_event(event)
84
- event.event_type.match(/calling\.call/) &&
84
+ event.event_type &&
85
+ event.event_type.match(/calling\.call/) &&
85
86
  !event.event_type.match(/receive/) &&
86
87
  (event.call_id == id || event.call_params[:tag] == tag)
87
88
  end
@@ -316,6 +317,7 @@ module Signalwire::Relay::Calling
316
317
  end
317
318
 
318
319
  def finish_call(params)
320
+ @client.unregister_handler(:event, @call_event_handler)
319
321
  terminate_components(params)
320
322
  client.calling.end_call(id)
321
323
  @busy = true if params[:reason] == Relay::DisconnectReason::BUSY
@@ -51,7 +51,7 @@ module Signalwire::Relay::Calling
51
51
  end
52
52
 
53
53
  def after_execute(execute_event)
54
- @url = execute_event.dig(:params, :params, :params, :url)
54
+ @url = execute_event.dig(:params, :params, :params, :url) if execute_event
55
55
  end
56
56
  end
57
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Signalwire
4
- VERSION = '2.3.3'
4
+ VERSION = '2.3.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signalwire
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 2.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - SignalWire Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-09 00:00:00.000000000 Z
11
+ date: 2020-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -370,7 +370,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
370
370
  - !ruby/object:Gem::Version
371
371
  version: '0'
372
372
  requirements: []
373
- rubygems_version: 3.0.6
373
+ rubygems_version: 3.1.2
374
374
  signing_key:
375
375
  specification_version: 4
376
376
  summary: Ruby client for Signalwire