signalwire 2.1.1 → 2.1.2

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
- SHA256:
3
- metadata.gz: 52a3ee7521ca981f6ba3708c08c52546d8f0552e4984efe371ff1bfcc92f6714
4
- data.tar.gz: 38325b6730da2aeae07b81be5e1576aa08eee4b207f7f9d43541316498ff4dd7
2
+ SHA1:
3
+ metadata.gz: a5ba44a20acd7bb12393399af0f7457543d60030
4
+ data.tar.gz: '069bc5cbbe6465918eab2e726d88b2120b5519a8'
5
5
  SHA512:
6
- metadata.gz: 71519d68edfdf1cf4531c48a9c3233965be0194d06e7f08d55810684f64af8a55c7bcdf0922344f3ecc67445fb79e6e83e38a070f5021ee670ae41fb822c3c57
7
- data.tar.gz: 96c15dd6087165ae39ef4504f552a85d1115828274c87c455ce60e448698be474412100094db1a5d621c7c5214fd37c7cb8a862be6a9b811650946dfe2436f1a
6
+ metadata.gz: b93d4efd4ab92f26fba1934720c1a03b50e17ad5576ea743af02654584170ff702a793fc2b201bb614a9b44d3ae82cd4feffc49de3d5790cd82b6bd88fcc82eb
7
+ data.tar.gz: 27353d85dd32d496b747c78659badb0c56df081cfdb37d707a6e8acb400d0e17399aecca433237b3a8c3efc633d96b29dd4cce346f8ef52b3b159fda58a1d535
data/CHANGELOG.md CHANGED
@@ -3,13 +3,20 @@ 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
- ## [2.1.1] 2019-08-01
6
+ ## [2.1.2] - 2019-08-01
7
+ ### Fixed
8
+ - Fix CPU usage
9
+ - Set default log level to INFO.
10
+ - Fix incorrect names for messaging parameters.
11
+ - Fix an issue when creating new calls.
12
+
13
+ ## [2.1.1] - 2019-08-01
7
14
  ### Fixed
8
15
  - Correctly set `peer` on calls
9
16
  ### Changed
10
17
  - Call `Consumer::teardown` on shutdown
11
18
 
12
- ## [2.1.0] 2019-07-29
19
+ ## [2.1.0] - 2019-07-29
13
20
  ### Added
14
21
  - Tap API for Relay
15
22
  - `:task` broadcast from client
@@ -0,0 +1,30 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
2
+ %w[
3
+ bundler/setup
4
+ signalwire
5
+ ].each { |f| require f }
6
+
7
+ Signalwire::Logger.logger.level = ::Logger::DEBUG
8
+
9
+ MY_NUMBER = "+12027621401"
10
+
11
+ class MyConsumer < Signalwire::Relay::Consumer
12
+ contexts ['incoming']
13
+ def on_incoming_call(call)
14
+ call.answer
15
+ call.play_tts 'Welcome to Relay'
16
+ dial = call.connect [[{ type: 'phone', params: { to_number: MY_NUMBER, from_number: call.from, timeout: 30 } }]]
17
+ pp "Connected"
18
+ pp dial.successful
19
+ dial.call.play_tts "Hello!" if dial.successful
20
+ pp "Waiting on Ending"
21
+ dial.call.wait_for_ending
22
+ call.play_tts 'finished. hanging up.'
23
+ call.hangup
24
+ rescue StandardError => e
25
+ logger.error e.inspect
26
+ logger.error e.backtrace
27
+ end
28
+ end
29
+
30
+ MyConsumer.new.run
@@ -56,10 +56,14 @@ module Signalwire::Blade
56
56
  logger.error "Error occurred: #{error.message}"
57
57
  end
58
58
 
59
- EM.next_tick { flush_queues }
59
+ schedule_flush_queues
60
60
  end
61
61
  end
62
62
 
63
+ def schedule_flush_queues
64
+ EM.add_timer(0.005) { flush_queues }
65
+ end
66
+
63
67
  def setup_started_event
64
68
  on :started do |_event|
65
69
  @connected = true
@@ -132,7 +136,7 @@ module Signalwire::Blade
132
136
  @outbound_queue.pop { |outbound| write(outbound) } until @outbound_queue.empty?
133
137
  end
134
138
 
135
- EM.next_tick { flush_queues }
139
+ schedule_flush_queues
136
140
  end
137
141
 
138
142
  def enqueue_inbound(message)
@@ -10,7 +10,7 @@ module Signalwire
10
10
  def logger
11
11
  @logger ||= begin
12
12
  logger = ::Logger.new(STDERR, progname: 'SignalWire', level: ::Logger::DEBUG)
13
- logger.level = ENV.fetch('SIGNALWIRE_LOG_LEVEL', ::Logger::WARN)
13
+ logger.level = ENV.fetch('SIGNALWIRE_LOG_LEVEL', ::Logger::INFO)
14
14
  logger
15
15
  end
16
16
  end
@@ -14,6 +14,7 @@ module Signalwire::Relay
14
14
 
15
15
  def initialize(client)
16
16
  @client = client
17
+ listen_for_created_calls
17
18
  end
18
19
 
19
20
  def calls
@@ -24,10 +25,19 @@ module Signalwire::Relay
24
25
  @client.contexts
25
26
  end
26
27
 
28
+ def listen_for_created_calls
29
+ @client.on :event, event_type: 'calling.call.state' do |event|
30
+ if !find_call_by_id(event.call_id)
31
+ created_call = Call.from_event(@client, event)
32
+ calls << created_call
33
+ end
34
+ end
35
+ end
36
+
27
37
  def receive(context:, &block)
28
38
  @client.on :event, event_type: 'calling.call.receive' do |event|
29
- logger.info "Starting up call for #{event.call_params}"
30
- call_obj = Signalwire::Relay::Calling::Call.from_event(self, event)
39
+ logger.debug "Receiving call: #{event.call_params}"
40
+ call_obj = Signalwire::Relay::Calling::Call.from_event(@client, event)
31
41
  calls << call_obj
32
42
  block.call(call_obj) if block_given?
33
43
  end
@@ -58,7 +68,7 @@ module Signalwire::Relay
58
68
  }
59
69
  }
60
70
  }
61
- call = Call.new(self, params)
71
+ call = Call.new(@client, params)
62
72
  calls << call
63
73
  call
64
74
  end
@@ -13,7 +13,7 @@ module Signalwire::Relay::Calling
13
13
 
14
14
  attr_reader :device, :type, :node_id, :context, :from, :to,
15
15
  :timeout, :tag, :client, :state, :previous_state, :components,
16
- :busy, :failed
16
+ :busy, :failed, :peer_call
17
17
  def_delegators :@client, :relay_execute
18
18
 
19
19
  def self.from_event(client, event)
@@ -64,7 +64,7 @@ module Signalwire::Relay::Calling
64
64
  def update_call_fields(call_state)
65
65
  @id = call_state[:call_id] if call_state[:call_id]
66
66
  @node_id = call_state[:node_id] if call_state[:node_id]
67
- @peer = call_state[:peer] if call_state[:peer]
67
+ @peer_call = call_state[:peer] if call_state[:peer]
68
68
  end
69
69
 
70
70
  def change_connect_state(new_connect_state)
@@ -96,7 +96,7 @@ module Signalwire::Relay::Calling
96
96
  end
97
97
 
98
98
  def peer
99
- @client.calling.find_call_by_id(@peer[:call_id]) if @peer && @peer[:call_id]
99
+ @client.calling.find_call_by_id(@peer_call[:call_id]) if @peer_call && @peer_call[:call_id]
100
100
  end
101
101
 
102
102
  def answer
@@ -21,8 +21,8 @@ module Signalwire::Relay
21
21
 
22
22
  def send(from:, to:, context:, body: nil, media: nil, tags: nil, region: nil)
23
23
  params = {
24
- from_number: from_number,
25
- to_number: to_number,
24
+ from_number: from,
25
+ to_number: to,
26
26
  context: context
27
27
  }
28
28
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Signalwire
4
- VERSION = '2.1.1'
4
+ VERSION = '2.1.2'
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.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - SignalWire Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-01 00:00:00.000000000 Z
11
+ date: 2019-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -268,6 +268,7 @@ files:
268
268
  - examples/relay/outbound_tap.rb
269
269
  - examples/relay/tasking/tasking_receive.rb
270
270
  - examples/relay/tasking/tasking_send.rb
271
+ - examples/relay/wait_for_ending.rb
271
272
  - lib/signalwire.rb
272
273
  - lib/signalwire/blade.rb
273
274
  - lib/signalwire/blade/connection.rb
@@ -356,7 +357,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
356
357
  - !ruby/object:Gem::Version
357
358
  version: '0'
358
359
  requirements: []
359
- rubygems_version: 3.0.3
360
+ rubyforge_project:
361
+ rubygems_version: 2.5.2.3
360
362
  signing_key:
361
363
  specification_version: 4
362
364
  summary: Ruby client for Signalwire