librevox 1.0.0.alpha1 → 1.0.0.alpha2

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: 6d47382ef56ccc15ea2aacf0e4bc5f4bf197fdb7338a25e7841a7f85a96ebe31
4
- data.tar.gz: 86736dac97c19aaa298693bfe99c3f75a9b829777f37ea20d2932a1f5221dc3b
3
+ metadata.gz: 52c30042c2b87d8bce357c5aaaa49147988cacc455f39f48f3517e2c29337990
4
+ data.tar.gz: 8b8d1608e69f8f5a8637233224e2d25b7d601d98f095b68ba266be60a887bb7b
5
5
  SHA512:
6
- metadata.gz: efea41f41b6e92608d8dbe69035cbc537c7c1da77c15767c92aa1679633d57c840f26ac37a740f4df3a9ef24a24103bad9bdf2a1ed514bc8d73fd33e0a9576f9
7
- data.tar.gz: 6a1502164b5df5387b6f1a12c65d379f3fb13caec7a27201c4aa97d1122a22ac667021991802f8158b53e3bd91d2b8b4a0f401709ebee9973331b960bfecff67
6
+ metadata.gz: dd87a95e593d39615cf34ba02b343ba2ab4ef2f8f6862494e4c23d98daf8f1e7f252bb887c15a51440f4c1650ed2bbe8c8c41db89c50d50ff77bb60e4efb3c6e
7
+ data.tar.gz: 655726a4f85cb4a4f8f6a546d4c254118d32712fbbd7d8a36a82f22850dffaa7503e8f241576c209c673a71179f016102bc32d20bd0cdfee47e77f4a701a7cc1
data/README.md CHANGED
@@ -171,12 +171,12 @@ Default ports are 8021 for inbound and 8084 for outbound.
171
171
 
172
172
  ## Closing Connections
173
173
 
174
- After a session ends (e.g. the caller hangs up), the outbound socket connection to FreeSWITCH remains open for post-session events. Close it manually when done to avoid lingering sessions. Use `done` (alias for `close_connection_after_writing`):
174
+ After a session ends (e.g. the caller hangs up), the outbound socket connection to FreeSWITCH remains open for post-session events. Close it manually when done to avoid lingering sessions:
175
175
 
176
176
  ```ruby
177
177
  class MyOutbound < Librevox::Listener::Outbound
178
178
  event :channel_hangup do
179
- done
179
+ disconnect
180
180
  end
181
181
  end
182
182
  ```
@@ -19,7 +19,7 @@ module Librevox
19
19
  listener = @handler.new(connection, @options)
20
20
 
21
21
  session_task = Async { listener.run_session }
22
- listener.read_loop
22
+ connection.read_loop { |msg| listener.receive_message(msg) }
23
23
  ensure
24
24
  session_task&.stop
25
25
  connection.close
@@ -50,7 +50,7 @@ module Librevox
50
50
 
51
51
  def command(msg)
52
52
  @command_mutex.acquire do
53
- send_data "#{msg}\n\n"
53
+ write "#{msg}\n\n"
54
54
  @reply_queue.dequeue
55
55
  end
56
56
  end
@@ -81,25 +81,17 @@ module Librevox
81
81
  def on_event(event)
82
82
  end
83
83
 
84
- def send_data(data)
84
+ def write(data)
85
85
  @connection&.write(data)
86
86
  end
87
87
 
88
- def read_loop
89
- while (msg = @connection.read_message)
90
- receive_message(msg)
91
- end
92
- end
93
-
94
88
  def run_session
95
89
  end
96
90
 
97
- def close_connection_after_writing
91
+ def disconnect
98
92
  @connection&.close
99
93
  end
100
94
 
101
- alias :done :close_connection_after_writing
102
-
103
95
  private
104
96
 
105
97
  def invoke_event_hooks(resp)
@@ -26,7 +26,7 @@ module Librevox
26
26
 
27
27
  def sendmsg(msg)
28
28
  @command_mutex.acquire do
29
- send_data "sendmsg\n#{msg}\n\n"
29
+ write "sendmsg\n#{msg}\n\n"
30
30
  @reply_queue.dequeue # command/reply ack
31
31
  end
32
32
  @app_complete_queue.dequeue # CHANNEL_EXECUTE_COMPLETE
@@ -24,6 +24,12 @@ module Librevox
24
24
  end
25
25
  end
26
26
 
27
+ def read_loop
28
+ while (msg = read_message)
29
+ yield msg
30
+ end
31
+ end
32
+
27
33
  def write(data)
28
34
  @stream.write(data)
29
35
  @stream.flush
@@ -18,7 +18,7 @@ module Librevox
18
18
  listener = @handler.new(connection)
19
19
 
20
20
  session_task = Async { listener.run_session }
21
- listener.read_loop
21
+ connection.read_loop { |msg| listener.receive_message(msg) }
22
22
  rescue => e
23
23
  Librevox.logger.error "Session error: #{e.full_message}"
24
24
  ensure
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Librevox
4
- VERSION = "1.0.0.alpha1"
4
+ VERSION = "1.0.0.alpha2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librevox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha1
4
+ version: 1.0.0.alpha2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Vangberg