@moq/net 0.4.0 → 0.4.1
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.
- package/announced.d.ts +14 -0
- package/announced.d.ts.map +1 -1
- package/announced.js.map +1 -1
- package/broadcast.d.ts +6 -3
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +9 -5
- package/broadcast.js.map +1 -1
- package/connection/accept.js +9 -1
- package/connection/accept.js.map +1 -1
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +10 -1
- package/connection/connect.js.map +1 -1
- package/connection/established.d.ts +2 -1
- package/connection/established.d.ts.map +1 -1
- package/connection/established.js.map +1 -1
- package/connection/forward.js +9 -2
- package/connection/forward.js.map +1 -1
- package/connection/handshake.d.ts +1 -0
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +3 -0
- package/connection/handshake.js.map +1 -1
- package/connection/pool.d.ts +8 -10
- package/connection/pool.d.ts.map +1 -1
- package/connection/pool.js +18 -8
- package/connection/pool.js.map +1 -1
- package/connection/reload.js +6 -6
- package/connection/reload.js.map +1 -1
- package/error.d.ts.map +1 -1
- package/error.js +21 -0
- package/error.js.map +1 -1
- package/ietf/adapter.d.ts +5 -1
- package/ietf/adapter.d.ts.map +1 -1
- package/ietf/adapter.js +27 -9
- package/ietf/adapter.js.map +1 -1
- package/ietf/connection.d.ts +1 -1
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +9 -5
- package/ietf/connection.js.map +1 -1
- package/ietf/error.js +27 -2
- package/ietf/error.js.map +1 -1
- package/ietf/hidden.d.ts +2 -0
- package/ietf/hidden.d.ts.map +1 -0
- package/ietf/hidden.js +30 -0
- package/ietf/hidden.js.map +1 -0
- package/ietf/index.d.ts +1 -0
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +1 -0
- package/ietf/index.js.map +1 -1
- package/ietf/object.d.ts +8 -2
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +17 -3
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +5 -0
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +20 -0
- package/ietf/parameters.js.map +1 -1
- package/ietf/properties.d.ts +1 -0
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +14 -0
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +19 -2
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +40 -6
- package/ietf/publish.js.map +1 -1
- package/ietf/publisher.js +114 -60
- package/ietf/publisher.js.map +1 -1
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +3 -4
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +8 -2
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +18 -8
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.js +189 -66
- package/ietf/subscriber.js.map +1 -1
- package/internal.d.ts +7 -0
- package/internal.d.ts.map +1 -1
- package/internal.js +11 -0
- package/internal.js.map +1 -1
- package/lite/announce.d.ts +46 -2
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +126 -11
- package/lite/announce.js.map +1 -1
- package/lite/connection.d.ts +1 -1
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +9 -3
- package/lite/connection.js.map +1 -1
- package/lite/publisher.js +168 -109
- package/lite/publisher.js.map +1 -1
- package/lite/subscribe.d.ts +10 -4
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +20 -10
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +10 -2
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +159 -93
- package/lite/subscriber.js.map +1 -1
- package/lite/version.d.ts +11 -0
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +56 -0
- package/lite/version.js.map +1 -1
- package/origin.d.ts +37 -18
- package/origin.d.ts.map +1 -1
- package/origin.js +248 -103
- package/origin.js.map +1 -1
- package/package.json +7 -3
- package/stream.d.ts +2 -2
- package/stream.d.ts.map +1 -1
- package/stream.js +16 -11
- package/stream.js.map +1 -1
- package/tail.d.ts +11 -0
- package/tail.d.ts.map +1 -0
- package/tail.js +121 -0
- package/tail.js.map +1 -0
- package/track.d.ts +33 -5
- package/track.d.ts.map +1 -1
- package/track.js +98 -30
- package/track.js.map +1 -1
- package/wire.d.ts +2 -0
- package/wire.d.ts.map +1 -1
- package/wire.js.map +1 -1
package/ietf/publisher.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* @ts-self-types="./publisher.d.ts" */
|
|
2
|
-
import { Signal } from "@moq/signals";
|
|
2
|
+
import { race, Signal } from "@moq/signals";
|
|
3
3
|
import { controlTimeout, error, reason, StreamCode, StreamError } from "../error.js";
|
|
4
4
|
import { routesEqual } from "../hop.js";
|
|
5
|
-
import { hooks } from "../internal.js";
|
|
5
|
+
import { hiddenBelow, hooks } from "../internal.js";
|
|
6
6
|
import * as Path from "../path.js";
|
|
7
7
|
import { Writer } from "../stream.js";
|
|
8
|
-
import { Milli } from "../time.js";
|
|
8
|
+
import { Milli, Timescale } from "../time.js";
|
|
9
9
|
import { TimeoutError, withTimeout } from "../util/timeout.js";
|
|
10
10
|
import * as Varint from "../varint.js";
|
|
11
11
|
import { wireOf } from "../wire.js";
|
|
@@ -16,12 +16,11 @@ import * as Filter from "./filter.js";
|
|
|
16
16
|
import { FetchFrame, Frame, Group as GroupMessage } from "./object.js";
|
|
17
17
|
import { fromWire, toWire } from "./priority.js";
|
|
18
18
|
import * as Properties from "./properties.js";
|
|
19
|
-
import { PublishDone } from "./publish.js";
|
|
19
|
+
import { PublishDone, PublishDoneStatus } from "./publish.js";
|
|
20
20
|
import { PublishNamespace, PublishNamespaceDone, PublishNamespaceOk } from "./publish_namespace.js";
|
|
21
21
|
import { RequestError, RequestOk } from "./request.js";
|
|
22
22
|
import { SubscribeError, SubscribeOk } from "./subscribe.js";
|
|
23
23
|
import { SubscribeNamespaceEntry, SubscribeNamespaceEntryDone, SubscribeNamespaceOk, } from "./subscribe_namespace.js";
|
|
24
|
-
import { TrackStatus } from "./track.js";
|
|
25
24
|
import { Version } from "./version.js";
|
|
26
25
|
/** First wait before re-offering a namespace the peer refused or we couldn't open for. */
|
|
27
26
|
const RETRY_BASE = 100;
|
|
@@ -40,11 +39,6 @@ function clusterFor(base, route) {
|
|
|
40
39
|
function sameAdvert(a, b) {
|
|
41
40
|
return a !== undefined && b !== undefined && a.identity === b.identity && routesEqual(a.route, b.route);
|
|
42
41
|
}
|
|
43
|
-
/** PUBLISH_DONE statuses this implementation emits. Stable across drafts 14 through 19. */
|
|
44
|
-
const PUBLISH_DONE_STATUS = {
|
|
45
|
-
INTERNAL_ERROR: 0x0,
|
|
46
|
-
TRACK_ENDED: 0x2,
|
|
47
|
-
};
|
|
48
42
|
/**
|
|
49
43
|
* How long one advertisement may take to be answered. Matches the Rust publisher, and the
|
|
50
44
|
* peer accepting the stream is only half the exchange: one it never answers on holds the
|
|
@@ -65,12 +59,10 @@ export class Publisher {
|
|
|
65
59
|
#quic;
|
|
66
60
|
#session;
|
|
67
61
|
#requiresSolicitation;
|
|
68
|
-
// The
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
// request if the peer asked for that (see {@link runSubscribeNamespace}).
|
|
73
|
-
#broadcasts;
|
|
62
|
+
// The origin this session serves, borrowed: it outlives the session, and closing the
|
|
63
|
+
// session leaves its broadcasts alone. The namespaces are advertised with an unsolicited
|
|
64
|
+
// PUBLISH_NAMESPACE (see {@link runPublishNamespaces}), or on request if the peer asked
|
|
65
|
+
// for that (see {@link runSubscribeNamespace}).
|
|
74
66
|
#advertised;
|
|
75
67
|
#publish;
|
|
76
68
|
// What every advertisement carries on a session that negotiated the MoQ Cluster
|
|
@@ -86,7 +78,6 @@ export class Publisher {
|
|
|
86
78
|
this.#quic = quic;
|
|
87
79
|
this.#session = session;
|
|
88
80
|
const origin = publish && wireOf(publish);
|
|
89
|
-
this.#broadcasts = origin?.broadcasts ?? new Signal(new Map());
|
|
90
81
|
this.#advertised = origin?.advertised ?? new Signal(new Map());
|
|
91
82
|
this.#publish = publish;
|
|
92
83
|
this.#requiresSolicitation = requiresSolicitation;
|
|
@@ -105,7 +96,7 @@ export class Publisher {
|
|
|
105
96
|
let refusal;
|
|
106
97
|
try {
|
|
107
98
|
broadcast =
|
|
108
|
-
this.#
|
|
99
|
+
this.#publish && (wireOf(this.#publish).local(name) ?? (await wireOf(this.#publish).demand(name)));
|
|
109
100
|
if (!broadcast) {
|
|
110
101
|
refusal = {
|
|
111
102
|
errorCode: toRequestCode("does_not_exist", "subscribe", version),
|
|
@@ -211,7 +202,7 @@ export class Publisher {
|
|
|
211
202
|
? // Declaring the timescale is what opts the track into timestamps; every
|
|
212
203
|
// object Timestamp below is in these units. We serve the newest group
|
|
213
204
|
// first, matching moq-lite.
|
|
214
|
-
{ timescale, groupOrder: Properties.DESCENDING }
|
|
205
|
+
{ timescale, priority: publisherPriority, groupOrder: Properties.DESCENDING }
|
|
215
206
|
: // INCLUDE_PROPERTIES=0. The block stays present but empty, which also means
|
|
216
207
|
// the track opts out of timestamps for this subscriber.
|
|
217
208
|
{},
|
|
@@ -232,6 +223,10 @@ export class Publisher {
|
|
|
232
223
|
},
|
|
233
224
|
// A reset is always the peer.
|
|
234
225
|
() => unsubscribe());
|
|
226
|
+
// Every group started, until its stream finishes or resets, and the data streams
|
|
227
|
+
// opened for PUBLISH_DONE to report.
|
|
228
|
+
const groups = new Set();
|
|
229
|
+
const streams = { opened: 0 };
|
|
235
230
|
// Serve track groups, racing with stream close (= Unsubscribe)
|
|
236
231
|
const serving = (async () => {
|
|
237
232
|
for (;;) {
|
|
@@ -247,7 +242,7 @@ export class Publisher {
|
|
|
247
242
|
group.close();
|
|
248
243
|
continue;
|
|
249
244
|
}
|
|
250
|
-
|
|
245
|
+
const task = this.#runGroup({
|
|
251
246
|
requestId: msg.requestId,
|
|
252
247
|
group,
|
|
253
248
|
timescale,
|
|
@@ -255,7 +250,10 @@ export class Publisher {
|
|
|
255
250
|
stamped: msg.propertiesWanted,
|
|
256
251
|
slice: groupSlice(range, group.sequence),
|
|
257
252
|
unsubscribed,
|
|
253
|
+
streams,
|
|
258
254
|
});
|
|
255
|
+
groups.add(task);
|
|
256
|
+
void task.finally(() => groups.delete(task));
|
|
259
257
|
}
|
|
260
258
|
})();
|
|
261
259
|
// The fill (when one was requested) runs alongside on its own fetch stream; its
|
|
@@ -269,15 +267,35 @@ export class Publisher {
|
|
|
269
267
|
timescale,
|
|
270
268
|
stamped: msg.propertiesWanted,
|
|
271
269
|
unsubscribed,
|
|
270
|
+
streams,
|
|
272
271
|
})
|
|
273
272
|
: Promise.resolve();
|
|
274
273
|
let publishError;
|
|
274
|
+
let ended = false;
|
|
275
275
|
try {
|
|
276
|
-
|
|
276
|
+
const served = Symbol("served");
|
|
277
|
+
ended =
|
|
278
|
+
(await race([Promise.all([serving, filling]).then(() => served), stream.reader.closed])) === served;
|
|
277
279
|
}
|
|
278
280
|
catch (err) {
|
|
279
281
|
publishError = error(err);
|
|
280
282
|
}
|
|
283
|
+
// PUBLISH_DONE waits until every stream this subscription will open is closed, as
|
|
284
|
+
// the draft requires, so its count is final. The subscriber leaving cancels the
|
|
285
|
+
// ones still queued instead.
|
|
286
|
+
await race([Promise.all(groups), unsubscribed]);
|
|
287
|
+
// Draft 14 on has no end location in PUBLISH_DONE: an END_OF_TRACK object is what
|
|
288
|
+
// tells the subscriber where the track ended.
|
|
289
|
+
const final = track.final();
|
|
290
|
+
if (ended && !publishError && final !== undefined) {
|
|
291
|
+
await this.#runEndOfTrack({
|
|
292
|
+
requestId: msg.requestId,
|
|
293
|
+
final,
|
|
294
|
+
publisherPriority,
|
|
295
|
+
unsubscribed,
|
|
296
|
+
streams,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
281
299
|
console.debug(`publish done: broadcast=${name} track=${track.name}`);
|
|
282
300
|
if (publishError) {
|
|
283
301
|
console.warn(`publish error: broadcast=${name} track=${track.name} error=${reason(publishError)}`);
|
|
@@ -290,7 +308,8 @@ export class Publisher {
|
|
|
290
308
|
requestId: version === Version.DRAFT_14 || version === Version.DRAFT_15 || version === Version.DRAFT_16
|
|
291
309
|
? msg.requestId
|
|
292
310
|
: undefined,
|
|
293
|
-
statusCode: publishError ?
|
|
311
|
+
statusCode: publishError ? PublishDoneStatus.INTERNAL_ERROR : PublishDoneStatus.TRACK_ENDED,
|
|
312
|
+
streamCount: BigInt(streams.opened),
|
|
294
313
|
reasonPhrase: publishError ? "internal error" : "track ended",
|
|
295
314
|
});
|
|
296
315
|
await done.encode(stream.writer, version);
|
|
@@ -320,7 +339,7 @@ export class Publisher {
|
|
|
320
339
|
* Runs a group and sends its frames using ObjectStream (Subgroup delivery mode).
|
|
321
340
|
*/
|
|
322
341
|
async #runGroup(options) {
|
|
323
|
-
const { requestId, group, timescale, publisherPriority, stamped, slice, unsubscribed } = options;
|
|
342
|
+
const { requestId, group, timescale, publisherPriority, stamped, slice, unsubscribed, streams } = options;
|
|
324
343
|
try {
|
|
325
344
|
// One stream per group is faster than a peer at its limit can retire them, so this
|
|
326
345
|
// is the one path that doesn't wait for a slot: the transport would serve the opens
|
|
@@ -335,6 +354,7 @@ export class Publisher {
|
|
|
335
354
|
group.close(new Error("no stream slot"));
|
|
336
355
|
return;
|
|
337
356
|
}
|
|
357
|
+
streams.opened += 1;
|
|
338
358
|
const header = new GroupMessage({
|
|
339
359
|
trackAlias: requestId,
|
|
340
360
|
groupId: group.sequence,
|
|
@@ -370,7 +390,7 @@ export class Publisher {
|
|
|
370
390
|
break;
|
|
371
391
|
// Reading from the filter's start drops the objects below it: they are outside
|
|
372
392
|
// the requested range, so skipping them is not a gap.
|
|
373
|
-
const read = await
|
|
393
|
+
const read = await race([hooks.readGroupFrame(group, slice.skip), stream.closed]);
|
|
374
394
|
if (!read)
|
|
375
395
|
break;
|
|
376
396
|
next = read.sequence + 1;
|
|
@@ -398,6 +418,43 @@ export class Publisher {
|
|
|
398
418
|
group.close();
|
|
399
419
|
}
|
|
400
420
|
}
|
|
421
|
+
/**
|
|
422
|
+
* Mark the track's end with an END_OF_TRACK object on its own stream, at object 0 of the
|
|
423
|
+
* group that will never exist.
|
|
424
|
+
*
|
|
425
|
+
* The last group's stream has usually finished before the track ends, so the marker cannot
|
|
426
|
+
* ride on it. A failure only costs the subscriber the early boundary.
|
|
427
|
+
*/
|
|
428
|
+
async #runEndOfTrack(options) {
|
|
429
|
+
const { requestId, final, publisherPriority, unsubscribed, streams } = options;
|
|
430
|
+
const version = this.#session.version;
|
|
431
|
+
const stream = await Writer.tryOpen(this.#quic, { cancel: unsubscribed, version }).catch(() => undefined);
|
|
432
|
+
if (!stream)
|
|
433
|
+
return;
|
|
434
|
+
streams.opened += 1;
|
|
435
|
+
try {
|
|
436
|
+
const header = new GroupMessage({
|
|
437
|
+
trackAlias: requestId,
|
|
438
|
+
groupId: final,
|
|
439
|
+
subGroupId: 0,
|
|
440
|
+
publisherPriority,
|
|
441
|
+
flags: {
|
|
442
|
+
hasExtensions: false,
|
|
443
|
+
hasSubgroup: false,
|
|
444
|
+
hasSubgroupObject: false,
|
|
445
|
+
hasEnd: false,
|
|
446
|
+
hasPriority: true,
|
|
447
|
+
firstObject: true,
|
|
448
|
+
},
|
|
449
|
+
});
|
|
450
|
+
await header.encode(stream, version);
|
|
451
|
+
await new Frame({ endOfTrack: true }).encode(stream, header.flags, Timescale.MILLI, version);
|
|
452
|
+
stream.close();
|
|
453
|
+
}
|
|
454
|
+
catch (err) {
|
|
455
|
+
stream.reset(error(err));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
401
458
|
/**
|
|
402
459
|
* Serve a draft-20 fill on its own fetch stream: the requested range, read from the
|
|
403
460
|
* group cache, capped at the Largest Object snapshot.
|
|
@@ -407,7 +464,7 @@ export class Publisher {
|
|
|
407
464
|
* fill-failure signal. Nothing here touches the subscription either way.
|
|
408
465
|
*/
|
|
409
466
|
async #runFill(options) {
|
|
410
|
-
const { requestId, fill, cache, timescale, stamped, unsubscribed } = options;
|
|
467
|
+
const { requestId, fill, cache, timescale, stamped, unsubscribed, streams } = options;
|
|
411
468
|
const version = this.#session.version;
|
|
412
469
|
// Everything is inside the try so the cache fork is released on every path out,
|
|
413
470
|
// including a transport failure while opening the stream.
|
|
@@ -420,6 +477,7 @@ export class Publisher {
|
|
|
420
477
|
console.debug(`fill stream failed to open: fill=${requestId}`);
|
|
421
478
|
return;
|
|
422
479
|
}
|
|
480
|
+
streams.opened += 1;
|
|
423
481
|
await stream.u53(FetchHeader.type);
|
|
424
482
|
await new FetchHeader({ requestId }).encode(stream, version);
|
|
425
483
|
if (fill.kind !== "group") {
|
|
@@ -469,11 +527,7 @@ export class Publisher {
|
|
|
469
527
|
if (fill.until !== undefined && next >= fill.until)
|
|
470
528
|
break;
|
|
471
529
|
// Reading from the fill's start drops everything below it; see the same read in #runGroup.
|
|
472
|
-
const frame = await
|
|
473
|
-
group.readFrameSequence({ from: Number(fill.skip) }),
|
|
474
|
-
stream.closed,
|
|
475
|
-
cancelled,
|
|
476
|
-
]);
|
|
530
|
+
const frame = await race([group.readFrameSequence({ from: Number(fill.skip) }), stream.closed, cancelled]);
|
|
477
531
|
if (left)
|
|
478
532
|
throw new Error("unsubscribed before the fill finished");
|
|
479
533
|
if (!frame)
|
|
@@ -489,10 +543,10 @@ export class Publisher {
|
|
|
489
543
|
/**
|
|
490
544
|
* Handles an incoming SUBSCRIBE_NAMESPACE on a bidi stream.
|
|
491
545
|
*
|
|
492
|
-
* This carries the advertisements
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
* broadcast. Draft-16+ streams Namespace entries inline; draft-14/15 predate those
|
|
546
|
+
* This carries the advertisements when the peer asked to be told on request (MoQ
|
|
547
|
+
* Solicit); otherwise {@link runPublishNamespaces} has already announced everything
|
|
548
|
+
* visible and repeating it here would leave the peer holding two sources for one
|
|
549
|
+
* broadcast, so only the hidden namespaces it may see ride here (MoQ Hidden). Draft-16+ streams Namespace entries inline; draft-14/15 predate those
|
|
496
550
|
* messages, so each advertisement is a PUBLISH_NAMESPACE request of its own.
|
|
497
551
|
*
|
|
498
552
|
* @internal
|
|
@@ -517,12 +571,11 @@ export class Publisher {
|
|
|
517
571
|
});
|
|
518
572
|
await ok.encode(stream.writer, version);
|
|
519
573
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
}
|
|
574
|
+
// Hidden namespaces are left out unless the peer opted in (MoQ Hidden). Unless the
|
|
575
|
+
// peer asked to be told only on request, it has already heard everything visible
|
|
576
|
+
// from the empty prefix unasked, so this stream carries only what that hid.
|
|
577
|
+
const carries = (covered) => (msg.hidden || !hiddenBelow(prefix, covered)) &&
|
|
578
|
+
(this.#requiresSolicitation || hiddenBelow(Path.empty(), covered));
|
|
526
579
|
// Reports whether the peer now holds the namespace: an inline entry always
|
|
527
580
|
// lands, but a PUBLISH_NAMESPACE request can be declined.
|
|
528
581
|
const advertise = async (suffix, snap) => {
|
|
@@ -568,7 +621,7 @@ export class Publisher {
|
|
|
568
621
|
const updated = new Map();
|
|
569
622
|
for (const [covered, snap] of advertised) {
|
|
570
623
|
const suffix = Path.stripPrefix(prefix, covered);
|
|
571
|
-
if (suffix === null)
|
|
624
|
+
if (suffix === null || !carries(covered))
|
|
572
625
|
continue;
|
|
573
626
|
updated.set(suffix, snap);
|
|
574
627
|
}
|
|
@@ -614,8 +667,8 @@ export class Publisher {
|
|
|
614
667
|
retry = outstanding ? Math.min(retry ? retry * 2 : RETRY_BASE, RETRY_MAX) : 0;
|
|
615
668
|
// Wait for the next change, or for the peer to unsubscribe.
|
|
616
669
|
const next = await (retry
|
|
617
|
-
?
|
|
618
|
-
:
|
|
670
|
+
? race([changed, stream.reader.closed, retryAfter(retry).then(() => advertised)])
|
|
671
|
+
: race([changed, stream.reader.closed]));
|
|
619
672
|
dispose();
|
|
620
673
|
if (!next)
|
|
621
674
|
break;
|
|
@@ -686,6 +739,9 @@ export class Publisher {
|
|
|
686
739
|
}
|
|
687
740
|
const updated = new Map();
|
|
688
741
|
for (const [covered, snap] of advertised) {
|
|
742
|
+
// Unasked, a hidden namespace stays off the wire (MoQ Hidden).
|
|
743
|
+
if (hiddenBelow(Path.empty(), covered))
|
|
744
|
+
continue;
|
|
689
745
|
updated.set(covered, snap);
|
|
690
746
|
}
|
|
691
747
|
// A namespace that is gone, or that a republish replaced, takes its refusal with
|
|
@@ -726,8 +782,8 @@ export class Publisher {
|
|
|
726
782
|
retry = outstanding ? Math.min(retry ? retry * 2 : RETRY_BASE, RETRY_MAX) : 0;
|
|
727
783
|
// Wait for the next change, which has already fired if one landed above.
|
|
728
784
|
const next = await (retry
|
|
729
|
-
?
|
|
730
|
-
:
|
|
785
|
+
? race([changed, closed, retryAfter(retry).then(() => advertised)])
|
|
786
|
+
: race([changed, closed]));
|
|
731
787
|
dispose?.();
|
|
732
788
|
if (!next)
|
|
733
789
|
break;
|
|
@@ -870,25 +926,23 @@ export class Publisher {
|
|
|
870
926
|
*/
|
|
871
927
|
async runTrackStatusRequest(msg, stream) {
|
|
872
928
|
const version = this.#session.version;
|
|
929
|
+
const errorCode = toRequestCode("not_supported", "track_status", version);
|
|
873
930
|
if (version === Version.DRAFT_14) {
|
|
874
|
-
//
|
|
875
|
-
await stream.writer.u53(
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
lastObjectId: 0n,
|
|
882
|
-
});
|
|
883
|
-
await status.encode(stream.writer, version);
|
|
931
|
+
// TRACK_STATUS_ERROR shares the SUBSCRIBE_ERROR body on draft-14.
|
|
932
|
+
await stream.writer.u53(0x0f);
|
|
933
|
+
await new SubscribeError({
|
|
934
|
+
requestId: msg.requestId,
|
|
935
|
+
errorCode,
|
|
936
|
+
reasonPhrase: "TRACK_STATUS is not supported",
|
|
937
|
+
}).encode(stream.writer, version);
|
|
884
938
|
}
|
|
885
939
|
else {
|
|
886
|
-
|
|
887
|
-
await
|
|
888
|
-
const ok = new RequestOk({
|
|
940
|
+
await stream.writer.u53(RequestError.id);
|
|
941
|
+
await new RequestError({
|
|
889
942
|
requestId: version === Version.DRAFT_15 || version === Version.DRAFT_16 ? msg.requestId : undefined,
|
|
890
|
-
|
|
891
|
-
|
|
943
|
+
errorCode,
|
|
944
|
+
reasonPhrase: "TRACK_STATUS is not supported",
|
|
945
|
+
}).encode(stream.writer, version);
|
|
892
946
|
}
|
|
893
947
|
stream.close();
|
|
894
948
|
}
|