asterism 0.12.0 → 0.14.0

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.
@@ -1,4 +1,4 @@
1
- # The noun-verb commands of the command line (node, app, object, status:
1
+ # The noun-verb commands of the command line (node, app, object, topic, status:
2
2
  # lib/asterism/cli.rb's NOUNS), `completion` and the hidden `__complete`
3
3
  # (lib/asterism/cli/complete.rb).
4
4
  module Asterism
@@ -57,7 +57,12 @@ module Asterism
57
57
  if a.nil?
58
58
  @err.puts "asterism: no application #{node}/#{app} is visible"
59
59
  code = 1
60
- elsif structured?
60
+ next
61
+ end
62
+ # Its own types too (one more get, ?types), when it defines some.
63
+ types = a["topics"] ? sv.topics(["#{node}/#{app}"]).dig("#{node}/#{app}", "types") : nil
64
+ a = a.except("objects").merge("types" => types, "objects" => a["objects"]) if types && !types.empty?
65
+ if structured?
61
66
  emit({ "node" => node }.merge(a))
62
67
  else
63
68
  app_block("#{node}/#{app}", a, 0)
@@ -126,18 +131,18 @@ module Asterism
126
131
  code = 0
127
132
  connect do |net, _sv|
128
133
  q = Queue.new
129
- net.session.subscribe(Values.key_expr(pattern), depth: 16) { |s| q << [s.key, s.payload, Time.now] }
130
- got = q.pop(timeout: wait)
134
+ hold net.zenoh.subscribe(Values.key_expr(pattern), depth: 16) { |s| q << [s, Time.now] }
135
+ got = pop_until(q, wait)
131
136
  if got.nil?
132
137
  @err.puts nothing_came(pattern, wait)
133
138
  code = 1
134
139
  next
135
140
  end
136
- e = Values.entry(*got)
141
+ e = sample_entry(*got)
137
142
  if structured?
138
143
  emit(e)
139
144
  else
140
- put_lines(got[2], e, nil).each { @out.puts _1 }
145
+ put_lines(got[1], e, nil).each { @out.puts _1 }
141
146
  end
142
147
  end
143
148
  code
@@ -151,21 +156,24 @@ module Asterism
151
156
  code = 0
152
157
  connect do |net, _sv|
153
158
  q = Queue.new
154
- net.session.subscribe(Values.key_expr(pattern), depth: 256) { |s| q << [s.key, s.payload, Time.now] }
159
+ hold net.zenoh.subscribe(Values.key_expr(pattern), depth: 256) { |s| q << [s, Time.now] }
155
160
  seen = 0
156
161
  last = {}
162
+ seq = Values::Seq.new
157
163
  until_stopped(net) do |left|
158
164
  got = q.pop(timeout: [left || 0.2, 0.2].min)
159
165
  next unless got
160
166
  seen += 1
161
- e = Values.entry(*got)
167
+ e = sample_entry(*got, seq: seq)
162
168
  if structured?
163
169
  emit_line(e)
164
170
  else
165
- whole = @opts[:raw] || !last.key?(e["key"])
166
- old = last[e["key"]]
167
- last[e["key"]] = e["value"]
168
- lines = whole ? put_lines(got[2], e, nil) : put_lines(got[2], e, old, again: true)
171
+ # A shared key's senders each their own (Values.lane).
172
+ lane = Values.lane(e["key"], e["from"])
173
+ whole = @opts[:raw] || !last.key?(lane)
174
+ old = last[lane]
175
+ last[lane] = e["value"]
176
+ lines = whole ? put_lines(got[1], e, nil) : put_lines(got[1], e, old, again: true)
169
177
  lines&.each { @out.puts _1 }
170
178
  end
171
179
  @out.flush
@@ -179,6 +187,113 @@ module Asterism
179
187
  code
180
188
  end
181
189
 
190
+ # ------------------------------------------------------------ topic
191
+
192
+ # The topics of the applications that match NODE/APP (* for a part;
193
+ # */* by default): node/app/name a line, with the type.
194
+ def cmd_topic_list(rest)
195
+ pattern = rest.shift || "*/*"
196
+ parts = pattern.split("/", -1)
197
+ unless parts.size == 2 && parts.none? { _1.empty? || (_1.include?("*") && _1 != "*") }
198
+ raise ArgumentError, "topic list: NODE/APP, * for a part (asterism topic list 'games/*')"
199
+ end
200
+ connect do |_net, sv|
201
+ list = sv.topics(sv.apps(pattern)).sort.flat_map do |path, h|
202
+ h["topics"].map do |t|
203
+ n, a = path.split("/")
204
+ e = { "path" => ::Asterism::Pubs.path(n, a, t["name"]) }
205
+ e["by"] = path if t["shared"] # a shared place: the application that declares it
206
+ e.merge(t.except("name"))
207
+ end
208
+ end
209
+ if structured?
210
+ emit(list)
211
+ else
212
+ list.each do |t|
213
+ by = t["by"] ? " #{paint("(#{t['shared']}, by #{t['by']})", :note)}" : ""
214
+ @out.puts "#{paint_path(t['path'])} #{paint(topic_about(t), :note)}#{by}"
215
+ end
216
+ end
217
+ end
218
+ 0
219
+ end
220
+
221
+ # One topic (node/app/name, the name may have more parts): its
222
+ # declaration, and the definition of its type when it is one of the
223
+ # application's own. A shared key (node/@shared/name, @shared/name):
224
+ # each application that declares it, with its own declaration and the
225
+ # definition of its type from its own types (senders may define one
226
+ # type name differently).
227
+ def cmd_topic_info(rest)
228
+ path = rest.shift.to_s
229
+ pl = ::Asterism::Pubs.place(path)
230
+ return shared_topic_info(path, pl) if pl && pl[0]
231
+ parts = path.split("/", -1)
232
+ if parts.size < 3 || parts.any? { _1.empty? || _1.include?("*") }
233
+ raise ArgumentError, "topic info: PATH is node/app/name (asterism topic info games/games/othello1/state)"
234
+ end
235
+ app = parts[0, 2].join("/")
236
+ name = parts[2..].join("/")
237
+ code = 0
238
+ connect do |_net, sv|
239
+ h = sv.topics([app])[app]
240
+ t = h && h["topics"].find { _1["name"] == name }
241
+ if t.nil?
242
+ @err.puts "asterism: no topic #{path} is declared#{h ? '' : " (#{app} does not answer)"}"
243
+ code = 1
244
+ next
245
+ end
246
+ out = { "path" => path }.merge(t.except("name"))
247
+ d = t["type"].is_a?(String) && h["types"][t["type"]]
248
+ out["definition"] = d if d
249
+ if structured?
250
+ emit(out)
251
+ else
252
+ @out.puts paint_path(path)
253
+ @out.puts " #{paint('type:', :note)} #{t['type'] || '(no type)'}"
254
+ @out.puts " #{paint('encoding:', :note)} #{t['encoding'] || 'msgpack'}"
255
+ @out.puts " #{paint('unit:', :note)} #{t['unit']}" if t["unit"]
256
+ @out.puts " #{paint('time:', :note)} the sender's, with each value" if t["ts"]
257
+ Text.wrap_text(t["desc"], style.width, first: " ").each { @out.puts _1 } if t["desc"]
258
+ types_block({ t["type"] => d }, 2, label: "definition:") if d
259
+ end
260
+ end
261
+ code
262
+ end
263
+
264
+ # topic info for a shared key: the publishers, each with its own
265
+ # declaration and type definition.
266
+ def shared_topic_info(path, pl)
267
+ code = 0
268
+ connect do |_net, sv|
269
+ apps = sv.apps(pl[0] == :node ? "#{pl[1]}/*" : "*/*")
270
+ pubs = sv.topics(apps).sort.filter_map do |app, h|
271
+ t = h["topics"].find { _1["name"] == path }
272
+ next unless t
273
+ e = { "by" => app }.merge(t.except("name", "shared"))
274
+ d = t["type"].is_a?(String) && h["types"][t["type"]]
275
+ e["definition"] = d if d
276
+ e
277
+ end
278
+ if pubs.empty?
279
+ @err.puts "asterism: no application declares #{path}"
280
+ code = 1
281
+ next
282
+ end
283
+ if structured?
284
+ emit({ "path" => path, "shared" => pl[0].to_s, "publishers" => pubs })
285
+ else
286
+ @out.puts "#{paint_path(path)} #{paint("(#{pl[0]})", :note)}"
287
+ pubs.each do |t|
288
+ @out.puts " #{paint('by', :note)} #{paint_path(t['by'])} #{paint(topic_about(t), :note)}"
289
+ Text.wrap_text(t["desc"], style.width, first: " ").each { @out.puts _1 } if t["desc"]
290
+ types_block({ t["type"] => t["definition"] }, 4, label: "definition:") if t["definition"]
291
+ end
292
+ end
293
+ end
294
+ code
295
+ end
296
+
182
297
  # ------------------------------------------------------------ status
183
298
 
184
299
  def cmd_status_get(rest)
@@ -283,7 +398,8 @@ module Asterism
283
398
  @out.flush
284
399
  # A connection still trying past the budget is left behind: the
285
400
  # process ends without waiting for it.
286
- Process.exit!(0) if @complete_abandoned
401
+ # (Not when it runs on a connection given to it: the program goes on.)
402
+ Process.exit!(0) if @complete_abandoned && !embedded?
287
403
  0
288
404
  end
289
405
 
@@ -315,7 +431,10 @@ module Asterism
315
431
 
316
432
  private
317
433
 
434
+ # On a connection given to the command line: asked every time (its
435
+ # program keeps what it needs; nothing is written here).
318
436
  def cached(entry, &blk)
437
+ return blk.call if @cli.embedded?
319
438
  net = @cli.complete_network(@words)
320
439
  return nil if net.none?
321
440
  dir = Complete::Cache.dir(@cli.env)
@@ -377,18 +496,29 @@ module Asterism
377
496
  end
378
497
 
379
498
  # PATH (node/app/object, * for a part) and KEY (the rest, ** by
380
- # default) as one pattern.
499
+ # default) as one pattern. A shared place's keys (docs/protocol.md
500
+ # 17): PATH node/@shared/name... (a node's, * for the node) or
501
+ # @shared/name... (the network's), then KEY the same way.
381
502
  def put_pattern!(rest, what)
382
503
  path = rest.shift
383
504
  key = rest.shift || "**"
384
505
  parts = path.to_s.split("/", -1)
385
- unless parts.size == 3 && parts.none? { _1.empty? || (_1.include?("*") && _1 != "*") }
506
+ shared = parts[0] == Values::SHARED || parts[1] == Values::SHARED
507
+ ok = shared ? parts.size >= 1 : parts.size == 3
508
+ unless ok && parts.none? { _1.empty? || (_1.include?("*") && _1 != "*") }
386
509
  raise ArgumentError, "#{what}: PATH is node/app/object (* for a part), then KEY (asterism #{what} " \
387
- "games/games/othello1 state)"
510
+ "games/games/othello1 state); a shared place's: node/@shared/name or @shared/name " \
511
+ "(asterism #{what} games/@shared/spectate '*/state')"
388
512
  end
389
513
  Values.check_pattern!("#{path}/#{key}")
390
514
  end
391
515
 
516
+ # Values.entry of a Zenoh sample received at t (its encoding and
517
+ # attachment too).
518
+ def sample_entry(sample, t, seq: nil)
519
+ Values.entry(sample.key, sample.payload, t, encoding: sample.encoding, attachment: sample.attachment, seq: seq)
520
+ end
521
+
392
522
  def nothing_came(pattern, seconds)
393
523
  "asterism: nothing came on #{pattern}#{seconds ? " in #{format('%g', seconds)} s" : ''} " \
394
524
  "(the router does not let this node read it, or it has not changed)"
@@ -396,19 +526,45 @@ module Asterism
396
526
 
397
527
  # The lines of one put received at t: the time, the key and the value
398
528
  # whole; again (the key's value before was old): a line for each thing
399
- # that changed in a Hash, the value whole otherwise (nil: no change).
529
+ # that changed in a Hash, the value whole otherwise (nil: no change). A
530
+ # value that is bytes in an encoding (a picture) shows as its encoding
531
+ # and size. A line comes first when values were lost before this one,
532
+ # or the sender started its numbers again (Values.entry). A shared
533
+ # value's key is followed by its sender (from games/room01).
400
534
  def put_lines(t, e, old, again: false)
401
535
  head = "#{paint(t.strftime('%H:%M:%S.%L'), :time)} "
402
536
  v = e["value"]
537
+ gap = put_gap(head, e)
403
538
  if again && old.is_a?(Hash) && v.is_a?(Hash)
404
539
  changes = Text.status_diff(old, v)
405
- return nil if changes.empty?
406
- return changes.map { |c| "#{head}#{paint(e['key'], :object)} #{change_text(c)}" }
540
+ return gap if changes.empty?
541
+ return gap.to_a + changes.map { |c| "#{head}#{put_key(e)} #{change_text(c)}" }
542
+ end
543
+ return gap if again && old == v && !e["format"].include?("/")
544
+ first = "#{head}#{put_key(e)}"
545
+ return [*gap, "#{first} #{paint("(#{e['format']}, #{e['bytes']} bytes)", :note)}"] if bytes_value?(e)
546
+ return [*gap, "#{first} #{Text.inline(v)}"] unless v.is_a?(Hash)
547
+ [*gap, first, *Text.status_lines(v, style.width, Text.width(head))]
548
+ end
549
+
550
+ # Whether a value is bytes in an encoding (shown by its size).
551
+ def bytes_value?(e)
552
+ e["format"].include?("/") && e["value"] == "(#{e['bytes']} bytes)"
553
+ end
554
+
555
+ # [the line] saying what was lost before a value, or nil.
556
+ def put_gap(head, e)
557
+ if e["restarted"]
558
+ ["#{head}#{put_key(e)} #{paint("(started again at #{e['seq']})", :note)}"]
559
+ elsif e["lost"]
560
+ ["#{head}#{put_key(e)} #{paint("(#{e['lost']} lost)", :note)}"]
407
561
  end
408
- return nil if again && old == v
409
- first = "#{head}#{paint(e['key'], :object)}"
410
- return ["#{first} #{Text.inline(v)}"] unless v.is_a?(Hash)
411
- [first, *Text.status_lines(v, style.width, Text.width(head))]
562
+ end
563
+
564
+ # A value's key as a line shows it, with a shared value's sender.
565
+ def put_key(e)
566
+ k = paint(e["key"], :object)
567
+ e["from"] ? "#{k} #{paint('from', :note)} #{paint(e['from'], :app)}" : k
412
568
  end
413
569
 
414
570
  def no_status(path)
@@ -428,6 +584,7 @@ module Asterism
428
584
  pad = " " * indent
429
585
  @out.puts "#{pad}#{paint(name, :app)}"
430
586
  status_block(a, indent + 2)
587
+ types_block(a["types"], indent + 2)
431
588
  return if a["objects"].empty?
432
589
  @out.puts "#{pad} #{paint('objects:', :note)}"
433
590
  a["objects"].each do |o|
@@ -439,10 +596,10 @@ module Asterism
439
596
 
440
597
  # The status's puts of one application, cleaned (Status.parse).
441
598
  def subscribe_status(net, path)
442
- net.session.subscribe("asterism/#{path}/@status") do |sample|
599
+ hold(net.zenoh.subscribe("asterism/#{path}/@status") do |sample|
443
600
  got = ::Asterism::Status.parse(sample.key, sample.payload)
444
601
  yield got[2] if got
445
- end
602
+ end)
446
603
  end
447
604
 
448
605
  # Yields until Ctrl-C, --duration or a lost connection (the seconds
@@ -453,10 +610,23 @@ module Asterism
453
610
  left = deadline && (deadline - now)
454
611
  break if left && left <= 0
455
612
  break unless net.connected?
613
+ break if stopped?
456
614
  yield left
457
615
  end
458
616
  end
459
617
 
618
+ # The next item of the queue within seconds (nil: none came, or stop:
619
+ # asked to end first).
620
+ def pop_until(queue, seconds)
621
+ deadline = now + seconds
622
+ loop do
623
+ left = deadline - now
624
+ return nil if left <= 0 || stopped?
625
+ got = queue.pop(timeout: [left, 0.2].min)
626
+ return got if got
627
+ end
628
+ end
629
+
460
630
  def now
461
631
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
462
632
  end
@@ -1,12 +1,13 @@
1
1
  # What `asterism nodes / objects / tree` and the MCP bridge read from the
2
- # network, on a connection that is already open (Asterism.connect): the
2
+ # network, on a connection that is already open (an Asterism::Connection): the
3
3
  # applications and objects from the liveliness tokens, then the meta of
4
- # the objects, the nodes' profiles and the applications' statuses
5
- # (docs/protocol.md 5, 7, 8) with one get for each node or application.
4
+ # the objects, the nodes' profiles and the applications' own profiles
5
+ # (their statuses, topics and types: docs/protocol.md 5, 7, 8, 10, 11)
6
+ # with one get for each node or application.
6
7
  #
7
- # Not one wildcard get for all (asterism/*/*/@status): behind a router's
8
+ # Not one wildcard get for all (asterism/*/*/@profile): behind a router's
8
9
  # access control a query must fit the rules of every node it would reach
9
- # (a game host may answer asterism/games/*/@status, not asterism/*/*/@status),
10
+ # (a game host may answer asterism/games/*/@profile, not asterism/*/*/@profile),
10
11
  # so a wildcard over the nodes is refused where the plain keys pass. The
11
12
  # gets go out at once and are read as their replies come (zenoh-c fills
12
13
  # them on its own threads), so a listing costs one time limit at most,
@@ -23,10 +24,12 @@ module Asterism
23
24
 
24
25
  attr_reader :timeout
25
26
 
26
- # own: this connection's "<node>/<app>", left out of the listings.
27
- def initialize(timeout: 2.0, own: nil)
27
+ # net: the connection to read on (an Asterism::Connection). own: this
28
+ # connection's "<node>/<app>", left out of the listings.
29
+ def initialize(net, timeout: 2.0, own: nil)
30
+ @net = net
28
31
  @timeout = timeout
29
- @own = own || "#{::Asterism.node_id}/#{::Asterism.app}"
32
+ @own = own || net.path
30
33
  @object_docs = {}
31
34
  end
32
35
 
@@ -38,7 +41,7 @@ module Asterism
38
41
  last = nil
39
42
  since = now
40
43
  loop do
41
- cur = [::Asterism.apps, ::Asterism.each("**").size]
44
+ cur = [@net.apps, @net.each("**").size]
42
45
  if cur != last
43
46
  last = cur
44
47
  since = now
@@ -50,7 +53,7 @@ module Asterism
50
53
 
51
54
  # The applications alive, "<node>/<app>", sorted (this one left out).
52
55
  def apps(pattern = "*/*")
53
- (::Asterism.apps(pattern) - [@own]).sort
56
+ (@net.apps(pattern) - [@own]).sort
54
57
  end
55
58
 
56
59
  # The nodes that have an application or an object alive (sorted).
@@ -61,7 +64,7 @@ module Asterism
61
64
  # The objects alive, "<node>/<app>/<object>", sorted (this
62
65
  # application's own left out).
63
66
  def objects(pattern = "**")
64
- ::Asterism.each(pattern).map(&:asterism_path).reject { _1.start_with?("#{@own}/") }.sort
67
+ @net.each(pattern).map(&:asterism_path).reject { _1.start_with?("#{@own}/") }.sort
65
68
  end
66
69
 
67
70
  # {path => [{"name", "arity"}, ...]} for the paths given (an object
@@ -102,19 +105,74 @@ module Asterism
102
105
  end
103
106
 
104
107
  # {"<node>/<app>" => status} of the applications that answered (one
105
- # get per application, all at once).
108
+ # get per application on its own profile, ?status, all at once).
106
109
  def statuses(list = apps)
110
+ app_profiles(list, "status").filter_map do |path, raw|
111
+ st = ::Asterism::Status.check(raw["status"])
112
+ [path, st] if st
113
+ end.to_h
114
+ end
115
+
116
+ # {"<node>/<app>" => {"topics" => [...], "types" => {...}}} of the
117
+ # applications that answered (one get per application on its own
118
+ # profile, ?pubs;types): the topics as Survey.topic_entry gives them,
119
+ # sorted by name, and the application's own types
120
+ # (Asterism::Types.check). An application without either is there
121
+ # with both empty.
122
+ def topics(list = apps)
123
+ app_profiles(list, "pubs;types").to_h do |path, raw|
124
+ [path, { "topics" => Survey.topic_list(::Asterism::Pubs.check(raw["pubs"]) || {}),
125
+ "types" => ::Asterism::Types.check(raw["types"]) || {} }]
126
+ end
127
+ end
128
+
129
+ # {"<node>/<app>" => the answer (a Hash)} of the applications whose
130
+ # profile (asterism/<node>/<app>/@profile, docs/protocol.md 8)
131
+ # answered, asked with params (nil: the status and the topics).
132
+ def app_profiles(list, params)
107
133
  out = {}
108
- gets(list.map { "asterism/#{_1}/@status" }).each do |key, replies|
109
- st = replies.first && ::Asterism::Status.check(::Asterism::Codec.unpack(replies.first[1]))
134
+ gets(list.map { "asterism/#{_1}/@profile" }, params: params).each do |key, replies|
135
+ raw = replies.first && ::Asterism::Codec.unpack(replies.first[1])
110
136
  parts = key.split("/")
111
- out["#{parts[1]}/#{parts[2]}"] = st if st
137
+ out["#{parts[1]}/#{parts[2]}"] = raw if raw.is_a?(Hash)
112
138
  end
113
139
  out
114
140
  end
115
141
 
142
+ # A topic's declaration (docs/protocol.md 10.1, cleaned) as the
143
+ # command line and the MCP bridge show it: {"name", "type" (a built-in
144
+ # type's name, or the application type's; absent: no type),
145
+ # "encoding" (absent: MessagePack), "unit", "desc", "ts" (true: the
146
+ # sender's time comes with each value)}. A shared topic's name is its
147
+ # entry ("<node>/@shared/<name>", "@shared/<name>") and "shared" says
148
+ # its place ("node", "global"; docs/protocol.md 17).
149
+ def self.topic_entry(name, decl)
150
+ h = { "name" => name }
151
+ pl = ::Asterism::Pubs.place(name)
152
+ h["shared"] = pl[0].to_s if pl && pl[0]
153
+ t = decl["t"]
154
+ if t.is_a?(Integer)
155
+ h["type"] = ::Asterism::Types::NAMES[t - 1] || t
156
+ elsif t
157
+ h["type"] = t
158
+ end
159
+ if decl["e"]
160
+ h["encoding"] = ::Asterism::Pubs.encoding_name(decl["e"]) || decl["e"]
161
+ end
162
+ h["unit"] = decl["u"] if decl["u"]
163
+ h["desc"] = decl["d"] if decl["d"]
164
+ h["ts"] = true if decl["ts"]
165
+ h
166
+ end
167
+
168
+ # The declarations ({name => declaration}) as topic entries, sorted.
169
+ def self.topic_list(pubs)
170
+ pubs.sort.map { |name, d| topic_entry(name, d) }
171
+ end
172
+
116
173
  # The tree: [{"node", "profile", "apps" => [{"app", "status",
117
- # "objects" => [{"name", "methods"}]}]}]. meta: false leaves the
174
+ # "topics" => [topic entries], "objects" => [{"name", "methods"}]}]}]
175
+ # ("status" and "topics" only when the application has them). meta: false leaves the
118
176
  # methods out (no meta gets); node: (and app:) narrow it to one node
119
177
  # (one application).
120
178
  def tree(meta: true, node: nil, app: nil)
@@ -124,7 +182,7 @@ module Asterism
124
182
  threads = []
125
183
  node_list = (app_list.map { _1.split("/")[0] } + objs.map { _1.split("/")[0] }).uniq
126
184
  threads << Thread.new { profiles(node_list) }
127
- threads << Thread.new { statuses(app_list) }
185
+ threads << Thread.new { app_profiles(app_list, nil) }
128
186
  threads << Thread.new { meta ? metas(objs) : {} }
129
187
  prof, stat, met = threads.map(&:value)
130
188
  by_node = Hash.new { |h, k| h[k] = {} }
@@ -136,7 +194,14 @@ module Asterism
136
194
  by_node.keys.sort.map do |n|
137
195
  apps = by_node[n].keys.sort.map do |ap|
138
196
  h = { "app" => ap }
139
- h["status"] = stat["#{n}/#{ap}"] if stat.key?("#{n}/#{ap}")
197
+ # Another protocol than this program's: said (its token's number).
198
+ v = @net.protocol_of("#{n}/#{ap}")
199
+ h["protocol"] = v if v && v != ::Asterism::PROTOCOL
200
+ pr = stat["#{n}/#{ap}"]
201
+ st = pr && ::Asterism::Status.check(pr["status"])
202
+ h["status"] = st if st
203
+ pubs = pr && ::Asterism::Pubs.check(pr["pubs"])
204
+ h["topics"] = Survey.topic_list(pubs) if pubs && !pubs.empty?
140
205
  h["objects"] = by_node[n][ap].sort.map do |name|
141
206
  e = { "name" => name }
142
207
  e["methods"] = met["#{n}/#{ap}/#{name}"] if met.key?("#{n}/#{ap}/#{name}")
@@ -156,7 +221,7 @@ module Asterism
156
221
  # Sends a get on each key at once and waits for all of them (at most
157
222
  # the time limit): {key => [[reply key, payload], ...]}.
158
223
  def gets(keys, params: nil)
159
- s = ::Asterism.session
224
+ s = @net.session
160
225
  ms = (@timeout * 1000).round
161
226
  pending = keys.to_h { |k| [k, s.get(k, timeout_ms: ms, params: params)] }
162
227
  out = keys.to_h { [_1, []] }