moqtail 0.13.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.
- package/README.md +43 -0
- package/dist/{client-BzncAN14.mjs → client-BW1agDFV.mjs} +1268 -686
- package/dist/{client-DahXR3l4.cjs → client-Z7egUKTO.cjs} +1240 -628
- package/dist/client.cjs +6 -1
- package/dist/client.d.cts +583 -331
- package/dist/client.d.mts +583 -331
- package/dist/client.mjs +2 -2
- package/dist/{index-C8pNnaj0.d.cts → index-DBbxKcc1.d.cts} +594 -357
- package/dist/{index-C8pNnaj0.d.mts → index-DBbxKcc1.d.mts} +594 -357
- package/dist/index.cjs +30 -16
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/model.cjs +1139 -489
- package/dist/model.d.cts +2 -2
- package/dist/model.d.mts +2 -2
- package/dist/model.mjs +1116 -475
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -417,6 +417,49 @@ if (result instanceof RequestError) {
|
|
|
417
417
|
}
|
|
418
418
|
```
|
|
419
419
|
|
|
420
|
+
#### Observing Control Messages
|
|
421
|
+
|
|
422
|
+
`onMessageSent` and `onMessageReceived` report every control message the client sends or receives, which is useful for logging, debugging, or building a message inspector. They cover both the control stream (SETUP, GOAWAY) and the bidirectional request streams that carry SUBSCRIBE, PUBLISH, FETCH, the namespace messages, and their replies.
|
|
423
|
+
|
|
424
|
+
Pass them when connecting so the SETUP exchange is reported as well:
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
const client = await MOQtailClient.new({
|
|
428
|
+
url: 'moqt://relay.example.com:4433',
|
|
429
|
+
callbacks: {
|
|
430
|
+
onMessageSent: (msg) => console.log('→', ControlMessageType[msg.getType()], msg),
|
|
431
|
+
onMessageReceived: (msg) => console.log('←', ControlMessageType[msg.getType()], msg),
|
|
432
|
+
},
|
|
433
|
+
})
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
The callbacks can also be assigned to `client.onMessageSent` and `client.onMessageReceived` after connecting. Request streams pick up the change straight away, but the control stream keeps the callbacks it was given at connect time.
|
|
437
|
+
|
|
438
|
+
A message is reported once it has been written to its stream, or once it has been fully decoded on arrival.
|
|
439
|
+
|
|
440
|
+
#### Observing Data Streams
|
|
441
|
+
|
|
442
|
+
`onDataEvent` reports every data stream the client opens (`direction: 'out'`) or accepts (`direction: 'in'`) as small records, which is enough to count streams, groups, subgroups, objects and bytes without touching payloads:
|
|
443
|
+
|
|
444
|
+
- `header`: once per stream when it opens. Subgroup streams carry the track alias and group and subgroup IDs; fetch streams carry the request ID. Both include the track name when the client knows it.
|
|
445
|
+
- `object`: once per object, with its group, subgroup and object IDs, its payload length, its status if it has one, and its LOC Timestamp property (`locTimestamp`) if it carries one.
|
|
446
|
+
- `end`: once per stream, with `reason` set to `'fin'`, `'reset'` (plus `resetCode`) or `'error'`.
|
|
447
|
+
|
|
448
|
+
Every record carries a `streamId`, so objects can be tied back to the header of the stream they arrived on, and `at`, the local time it was written or read as `performance.now()`. Differences in `at` give interarrival times and jitter; comparing `performance.timeOrigin + at` with a sender's `locTimestamp` gives latency, provided both ends agree on the timestamp's unit and their clocks are in sync.
|
|
449
|
+
|
|
450
|
+
```typescript
|
|
451
|
+
const client = await MOQtailClient.new({
|
|
452
|
+
url: 'moqt://relay.example.com:4433',
|
|
453
|
+
callbacks: {
|
|
454
|
+
onDataEvent: (event) => {
|
|
455
|
+
if (event.kind === 'object') bytesByDirection[event.direction] += event.payloadLength
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
})
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
The callback runs for every object, so keep it cheap: update counters there and render them on a timer.
|
|
462
|
+
|
|
420
463
|
## Utilities
|
|
421
464
|
|
|
422
465
|
The MOQtail library provides several utility classes to help with common streaming scenarios:
|