rsmp 0.1.6 → 0.1.7

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: d6f7fa1f60ca721461cbd01259dbce26eaa84053a4f30417ab2fda58a6036488
4
- data.tar.gz: 9a9a7585b0364d3359c96de831c16d6f2cf6efb831a1460460d897291e089235
3
+ metadata.gz: 5cabe89d692eb93c0d2e5af449152ff5967b1318fd0163384a57c975673ffe87
4
+ data.tar.gz: cb53ef7c36c6609eed242e67db16fbf7a57455ca06de90599cb15e324a4cbc87
5
5
  SHA512:
6
- metadata.gz: c0e52d579f96ca22e6e836b137d48d894ed9007d8a638cfcd8adbaa2a4bcc9af7999c10ba9232ff4cef1cd83f30f0c0aef7da0ad0e684e73950bce36d45ac9be
7
- data.tar.gz: 51a1b83230b74632bd37be1eb48f5f435fcb597e6a9b26e22f5cace165f20a8a3bfed5c866281cba590f9e188d05d073b2d8c3e3bafd76e69858aeaf7c37a185
6
+ metadata.gz: 9520a1bd0b66eb19d7b17fda09cc8fcd1efb2219c098bf315faa0d04ba953a0e4b5ab823a8bbc425697635fac49e04b777b9dd2ec481f7651c0397c832aed2b0
7
+ data.tar.gz: a09905ee1f2128a44cbff599f36fa166601a69d97bd2f814c4d0523dfb68bbe5deafdea599b42d6dc9a251e14a48fb5b8b5f8b5a32af2b3dd8ada964b928b59b
data/lib/rsmp/node.rb CHANGED
@@ -17,6 +17,7 @@ module RSMP
17
17
  task.annotate self.class
18
18
  @task = task
19
19
  start_action
20
+ idle
20
21
  end
21
22
  rescue Errno::EADDRINUSE => e
22
23
  log "Cannot start: #{e.to_s}", level: :error
@@ -25,6 +26,12 @@ module RSMP
25
26
  exiting
26
27
  end
27
28
 
29
+ def idle
30
+ loop do
31
+ @task.sleep 60
32
+ end
33
+ end
34
+
28
35
  def stop
29
36
  @task.stop if @task
30
37
  end
data/lib/rsmp/probe.rb CHANGED
@@ -94,10 +94,20 @@ module RSMP
94
94
 
95
95
  def matches? item
96
96
  raise ArgumentError unless item
97
- return false if @options[:type] && (item[:message] == nil || (item[:message].type != @options[:type]))
97
+
98
+ if @options[:type]
99
+ return false if item[:message] == nil
100
+ if @options[:type].is_a? Array
101
+ return false unless @options[:type].include? item[:message].type
102
+ else
103
+ return false unless item[:message].type == @options[:type]
104
+ end
105
+ end
98
106
  return if @options[:level] && item[:level] != @options[:level]
99
107
  return false if @options[:with_message] && !(item[:direction] && item[:message])
100
- return false if @block && @block.call(item) == false
108
+ if @block
109
+ return false if @block.call(item) == false
110
+ end
101
111
  true
102
112
  end
103
113
  end
@@ -134,7 +134,7 @@ module RSMP
134
134
  "sS" => status_list
135
135
  })
136
136
  send_message message
137
- return message, wait_for_status_response(component: component, timeout: timeout)
137
+ return message, wait_for_status_response(message: message, timeout: timeout)
138
138
  end
139
139
 
140
140
  def process_status_response message
@@ -143,9 +143,17 @@ module RSMP
143
143
  end
144
144
 
145
145
  def wait_for_status_response options
146
- raise ArgumentError unless options[:component]
147
- item = @archive.capture(@task, options.merge(type: "StatusResponse", with_message: true, num: 1)) do |item|
148
- # check component
146
+ raise ArgumentError unless options[:message]
147
+ item = @archive.capture(@task, options.merge(
148
+ type: ['StatusResponse','MessageNotAck'],
149
+ with_message: true,
150
+ num: 1
151
+ )) do |item|
152
+ if item[:message].type == 'MessageNotAck'
153
+ next item[:message].attribute('oMId') == options[:message].m_id
154
+ elsif item[:message].type == 'StatusResponse'
155
+ next item[:message].attribute('cId') == options[:message].attribute('cId')
156
+ end
149
157
  end
150
158
  item[:message] if item
151
159
  end
@@ -30,7 +30,8 @@ module RSMP
30
30
  'status_response_timeout' => 1,
31
31
  'status_update_timeout' => 1,
32
32
  'site_connect_timeout' => 2,
33
- 'site_ready_timeout' => 1
33
+ 'site_ready_timeout' => 1,
34
+ 'stop_after_first_session' => false
34
35
  }
35
36
 
36
37
  if options[:supervisor_settings]
@@ -128,6 +129,8 @@ module RSMP
128
129
  proxy.run # will run until the site disconnects
129
130
  @proxies.delete proxy
130
131
  site_ids_changed
132
+
133
+ stop if @supervisor_settings['stop_after_first_session']
131
134
  end
132
135
 
133
136
  def site_ids_changed
@@ -174,6 +174,7 @@ module RSMP
174
174
  def process_status_subcribe message
175
175
  log "Received #{message.type}", message: message, level: :log
176
176
 
177
+
177
178
  # @status_subscriptions is organized by component/code/name, for example:
178
179
  #
179
180
  # {"AA+BBCCC=DDDEE002"=>{"S001"=>["number"]}}
data/lib/rsmp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RSMP
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/rsmp/wait.rb CHANGED
@@ -5,7 +5,7 @@ module RSMP
5
5
 
6
6
  def self.wait_for task, condition, timeout, &block
7
7
  task.with_timeout(timeout) do
8
- loop do
8
+ while task.running? do
9
9
  value = condition.wait
10
10
  result = yield value
11
11
  return result if result # return result of check, if not nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Tin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-08 00:00:00.000000000 Z
11
+ date: 2019-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -357,7 +357,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
357
357
  - !ruby/object:Gem::Version
358
358
  version: '0'
359
359
  requirements: []
360
- rubygems_version: 3.0.6
360
+ rubygems_version: 3.0.3
361
361
  signing_key:
362
362
  specification_version: 4
363
363
  summary: RoadSide Message Protocol (RSMP) library.