@dimchansky/meshpost 0.6.0 → 0.7.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/dist/blob.js +36 -36
- package/dist/channel.d.ts +4 -0
- package/dist/channel.js +4 -0
- package/dist/combine.d.ts +9 -2
- package/dist/combine.js +35 -33
- package/dist/index.d.ts +2 -1
- package/dist/mqtt.js +59 -109
- package/dist/nostr.js +71 -131
- package/dist/peer-link.js +983 -0
- package/dist/presence.js +74 -0
- package/dist/public.js +16 -23
- package/dist/relay-core.js +219 -143
- package/dist/room-reclaim.js +5 -1
- package/dist/room.js +300 -463
- package/dist/rpc.js +25 -28
- package/dist/signaling.js +2 -11
- package/dist/state.js +22 -31
- package/dist/tabs.js +6 -50
- package/dist/voice-mic.js +496 -0
- package/dist/voice-remote.js +568 -0
- package/dist/voice.d.ts +8 -0
- package/dist/voice.js +71 -816
- package/dist/ws.js +20 -58
- package/docs/adr/0001-room-internals-and-channel-budget.md +31 -0
- package/docs/api.md +6 -4
- package/docs/behavior.md +4 -4
- package/package.json +4 -2
- package/dist/room-hello.js +0 -129
- package/dist/room-ice.js +0 -115
- package/dist/room-media.js +0 -477
- package/dist/voice-helpers.js +0 -100
- package/dist/voice-meter.d.ts +0 -1
- package/dist/voice-meter.js +0 -79
- /package/dist/{room-hello.d.ts → peer-link.d.ts} +0 -0
- /package/dist/{room-ice.d.ts → presence.d.ts} +0 -0
- /package/dist/{room-media.d.ts → voice-mic.d.ts} +0 -0
- /package/dist/{voice-helpers.d.ts → voice-remote.d.ts} +0 -0
package/dist/room.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { isValidPeerIdentity } from './identity.js';
|
|
2
2
|
import { createListeners, reportAsyncError } from './listeners.js';
|
|
3
|
-
import {
|
|
4
|
-
import { maxTrickleCandidates, setAndPublishLocalDescription } from './room-ice.js';
|
|
5
|
-
import { createRoomMedia, maxRemoteStreamsPerPeer, maxRtcControlBytes, rtcControlPrefix } from './room-media.js';
|
|
3
|
+
import { createPeerLink, maxTrickleCandidates, streamTagPattern } from './peer-link.js';
|
|
6
4
|
import { createSessionReclaim } from './room-reclaim.js';
|
|
7
|
-
import { parsePeerStats } from './room-stats.js';
|
|
8
5
|
import { isSignal, randomUuid, withLoopbackFallback } from './signaling.js';
|
|
9
6
|
const roomInternals = new WeakMap();
|
|
10
7
|
/** @internal */
|
|
@@ -47,19 +44,66 @@ export function onRoomClose(room, fn) {
|
|
|
47
44
|
export function getRoomRemoteStreams(room) {
|
|
48
45
|
return roomInternals.get(room)?.getRemoteStreams() ?? [];
|
|
49
46
|
}
|
|
47
|
+
/** @internal */
|
|
48
|
+
export function bindRoomLifecycle(room, onShutdown) {
|
|
49
|
+
const controller = new AbortController();
|
|
50
|
+
let closed = isRoomClosed(room);
|
|
51
|
+
let offClose;
|
|
52
|
+
const close = () => {
|
|
53
|
+
if (closed)
|
|
54
|
+
return;
|
|
55
|
+
closed = true;
|
|
56
|
+
offClose?.();
|
|
57
|
+
offClose = undefined;
|
|
58
|
+
controller.abort();
|
|
59
|
+
onShutdown();
|
|
60
|
+
};
|
|
61
|
+
if (closed) {
|
|
62
|
+
controller.abort();
|
|
63
|
+
onShutdown();
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const stop = onRoomClose(room, close);
|
|
67
|
+
if (closed)
|
|
68
|
+
stop();
|
|
69
|
+
else
|
|
70
|
+
offClose = stop;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
signal: controller.signal,
|
|
74
|
+
isClosed: () => closed,
|
|
75
|
+
close
|
|
76
|
+
};
|
|
77
|
+
}
|
|
50
78
|
/** Built-in Cloudflare and Google public STUN servers used by default. */
|
|
51
79
|
export const defaultIceServers = Object.freeze([
|
|
52
80
|
Object.freeze({ urls: 'stun:stun.cloudflare.com:3478' }),
|
|
53
81
|
Object.freeze({ urls: 'stun:stun.l.google.com:19302' }),
|
|
54
82
|
Object.freeze({ urls: 'stun:stun1.l.google.com:19302' })
|
|
55
83
|
]);
|
|
56
|
-
const maxPacket = 16 * 1024;
|
|
57
|
-
const bufferLimit = { unreliable: 64 * 1024, reliable: 256 * 1024 };
|
|
58
84
|
const establishTimeout = 35_000;
|
|
59
85
|
const gatherTimeoutDefault = 2_500;
|
|
60
86
|
const maxPeersDefault = 32;
|
|
61
|
-
|
|
62
|
-
|
|
87
|
+
function parseStreamTarget(toOrOptions, allowTag) {
|
|
88
|
+
if (typeof toOrOptions === 'string')
|
|
89
|
+
return { to: toOrOptions };
|
|
90
|
+
if (toOrOptions === undefined)
|
|
91
|
+
return {};
|
|
92
|
+
if (!toOrOptions || typeof toOrOptions !== 'object' || Array.isArray(toOrOptions)) {
|
|
93
|
+
throw new TypeError(allowTag ? 'Invalid addStream options' : 'Invalid removeStream options');
|
|
94
|
+
}
|
|
95
|
+
if (toOrOptions.to !== undefined && typeof toOrOptions.to !== 'string') {
|
|
96
|
+
throw new TypeError('Invalid target peer ID');
|
|
97
|
+
}
|
|
98
|
+
const tag = allowTag ? toOrOptions.tag : undefined;
|
|
99
|
+
if (tag !== undefined && (typeof tag !== 'string' || !streamTagPattern.test(tag))) {
|
|
100
|
+
throw new TypeError('Invalid stream tag');
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
...(toOrOptions.to !== undefined ? { to: toOrOptions.to } : {}),
|
|
104
|
+
...(tag !== undefined ? { tag } : {})
|
|
105
|
+
};
|
|
106
|
+
}
|
|
63
107
|
/** Start discovery immediately. Membership becomes observable as peer links open. */
|
|
64
108
|
export function joinRoom(name, options) {
|
|
65
109
|
if (typeof name !== 'string' || !/^[a-zA-Z0-9_-]{1,64}$/.test(name))
|
|
@@ -125,36 +169,39 @@ export function joinRoom(name, options) {
|
|
|
125
169
|
isStopped: () => stopped,
|
|
126
170
|
sendUnloadLeaveNotices() {
|
|
127
171
|
for (const peer of peers.values()) {
|
|
128
|
-
|
|
129
|
-
if (reliable?.readyState === 'open') {
|
|
130
|
-
try {
|
|
131
|
-
reliable.send(leaveNotice);
|
|
132
|
-
}
|
|
133
|
-
catch {
|
|
134
|
-
// Best-effort unload departure hint.
|
|
135
|
-
}
|
|
136
|
-
}
|
|
172
|
+
peer.link?.sendUnloadLeave();
|
|
137
173
|
}
|
|
138
174
|
}
|
|
139
175
|
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
176
|
+
// Room-level desired local streams & tags (link-level SDP/senders live inside PeerLink).
|
|
177
|
+
const broadcastStreams = new Set();
|
|
178
|
+
const peerStreams = new Map();
|
|
179
|
+
const localStreamTags = new Map();
|
|
180
|
+
const desiredStreamsFor = (peerId) => {
|
|
181
|
+
const set = new Set(broadcastStreams);
|
|
182
|
+
const targeted = peerStreams.get(peerId);
|
|
183
|
+
if (targeted) {
|
|
184
|
+
for (const s of targeted)
|
|
185
|
+
set.add(s);
|
|
186
|
+
}
|
|
187
|
+
return set;
|
|
188
|
+
};
|
|
189
|
+
const isStreamRegistered = (stream) => {
|
|
190
|
+
if (broadcastStreams.has(stream))
|
|
191
|
+
return true;
|
|
192
|
+
for (const set of peerStreams.values()) {
|
|
193
|
+
if (set.has(stream))
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
return false;
|
|
197
|
+
};
|
|
198
|
+
const extendedGather = options.iceGatheringTimeoutMs === undefined
|
|
199
|
+
? Math.min(10_000, Math.floor(timeout / 2))
|
|
200
|
+
: gatherTimeout;
|
|
147
201
|
const prepareRemoteSdp = (signal) => rtcConfig.iceTransportPolicy === 'relay' ? signal.sdp : withLoopbackFallback(signal).sdp;
|
|
148
202
|
const prepareRemoteCandidates = (signal) => rtcConfig.iceTransportPolicy === 'relay'
|
|
149
203
|
? signal.candidates
|
|
150
204
|
: withLoopbackFallback(signal).candidates;
|
|
151
|
-
const applyRemoteCandidates = (peer, link, candidates) => {
|
|
152
|
-
for (const item of candidates) {
|
|
153
|
-
if (stopped || peer.link !== link)
|
|
154
|
-
return;
|
|
155
|
-
void link.pc.addIceCandidate(item).catch(() => { });
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
205
|
const canReachPeer = (id) => {
|
|
159
206
|
if (!signaling)
|
|
160
207
|
return false;
|
|
@@ -170,381 +217,138 @@ export function joinRoom(name, options) {
|
|
|
170
217
|
discover(peer);
|
|
171
218
|
}, delay);
|
|
172
219
|
}
|
|
173
|
-
function
|
|
174
|
-
if (peer.link !== link)
|
|
175
|
-
return;
|
|
176
|
-
delete peer.link;
|
|
177
|
-
if (link.accepted)
|
|
178
|
-
peer.previous = link.attempt;
|
|
179
|
-
if (peer.earlyIce?.attempt === link.attempt)
|
|
180
|
-
delete peer.earlyIce;
|
|
181
|
-
clearTimeout(link.deadline);
|
|
182
|
-
clearTimeout(link.gather);
|
|
183
|
-
clearTimeout(link.iceFlush);
|
|
184
|
-
clearTimeout(link.grace);
|
|
185
|
-
const reliable = link.channels.reliable;
|
|
186
|
-
if (flushLeave && reliable.readyState === 'open') {
|
|
187
|
-
// Give SCTP a bounded opportunity to deliver the departure before closing DTLS.
|
|
188
|
-
const closeTimer = setTimeout(() => link.pc.close(), 750);
|
|
189
|
-
reliable.addEventListener('close', () => {
|
|
190
|
-
clearTimeout(closeTimer);
|
|
191
|
-
link.pc.close();
|
|
192
|
-
}, { once: true });
|
|
193
|
-
try {
|
|
194
|
-
reliable.send(leaveNotice);
|
|
195
|
-
reliable.close();
|
|
196
|
-
}
|
|
197
|
-
catch {
|
|
198
|
-
clearTimeout(closeTimer);
|
|
199
|
-
link.pc.close();
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
else
|
|
203
|
-
link.pc.close();
|
|
220
|
+
function finishDrop(peer, link, endedStreams, wasReady, shouldRetry, error) {
|
|
204
221
|
if (!peer.advertised)
|
|
205
222
|
peers.delete(peer.id);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
peerStreamEndListeners.fire(peer.id, stream, media.remoteMetaFor(link, stream.id));
|
|
209
|
-
}
|
|
223
|
+
for (const [stream, meta] of endedStreams) {
|
|
224
|
+
peerStreamEndListeners.fire(peer.id, stream, meta);
|
|
210
225
|
}
|
|
211
|
-
|
|
212
|
-
if (link.ready)
|
|
226
|
+
if (wasReady)
|
|
213
227
|
leaves.fire(peer.id);
|
|
214
228
|
if (shouldRetry)
|
|
215
229
|
retry(peer);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
delete peer.retry;
|
|
220
|
-
const pc = new PeerConnection(rtcConfig);
|
|
221
|
-
// Fixed stream IDs let both endpoints create identical channels without glare.
|
|
222
|
-
let channels;
|
|
223
|
-
try {
|
|
224
|
-
channels = {
|
|
225
|
-
unreliable: pc.createDataChannel('meshpost/1/unreliable', {
|
|
226
|
-
negotiated: true,
|
|
227
|
-
id: 0,
|
|
228
|
-
ordered: false,
|
|
229
|
-
maxRetransmits: 0,
|
|
230
|
-
protocol: appId
|
|
231
|
-
}),
|
|
232
|
-
reliable: pc.createDataChannel('meshpost/1/reliable', {
|
|
233
|
-
negotiated: true,
|
|
234
|
-
id: 1,
|
|
235
|
-
ordered: true,
|
|
236
|
-
protocol: appId
|
|
237
|
-
})
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
catch (error) {
|
|
241
|
-
pc.close();
|
|
242
|
-
throw error;
|
|
243
|
-
}
|
|
244
|
-
const link = {
|
|
245
|
-
pc,
|
|
246
|
-
channels,
|
|
247
|
-
attempt,
|
|
248
|
-
channelsOpen: false,
|
|
249
|
-
helloSent: false,
|
|
250
|
-
helloReceived: false,
|
|
251
|
-
helloVerified: false,
|
|
252
|
-
ready: false,
|
|
253
|
-
accepted: false,
|
|
254
|
-
published: false,
|
|
255
|
-
answerApplied: false,
|
|
256
|
-
remoteDescApplied: false,
|
|
257
|
-
userId: null,
|
|
258
|
-
verifiedUserId: null,
|
|
259
|
-
reclaimCommit: null,
|
|
260
|
-
remoteReclaimCommit: null,
|
|
261
|
-
pendingReclaimMatch: null,
|
|
262
|
-
pendingCandidates: [],
|
|
263
|
-
rtcQueue: Promise.resolve(),
|
|
264
|
-
rtcPending: 0,
|
|
265
|
-
renegotiateQueued: false,
|
|
266
|
-
pendingStreamEnds: new Set(),
|
|
267
|
-
senders: new Map(),
|
|
268
|
-
remoteStreams: new Map(),
|
|
269
|
-
remoteStreamTags: new Map()
|
|
270
|
-
};
|
|
271
|
-
// Attach active local streams before initial createOffer() on the offerer for 0-RTT media setup.
|
|
272
|
-
if (self < peer.id) {
|
|
273
|
-
for (const stream of media.desiredStreamsFor(peer.id)) {
|
|
274
|
-
media.attachStreamToLink(link, stream);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
const earlyStreams = [];
|
|
278
|
-
pc.ontrack = (event) => {
|
|
279
|
-
if (stopped || peer.link !== link)
|
|
280
|
-
return;
|
|
281
|
-
const stream = event.streams[0] ??
|
|
282
|
-
(typeof MediaStream === 'function' ? new MediaStream([event.track]) : undefined);
|
|
283
|
-
if (!stream)
|
|
284
|
-
return;
|
|
285
|
-
if (link.remoteStreams.has(stream.id) || link.remoteStreams.size >= maxRemoteStreamsPerPeer)
|
|
286
|
-
return;
|
|
287
|
-
link.remoteStreams.set(stream.id, stream);
|
|
288
|
-
if (link.ready)
|
|
289
|
-
peerStreamListeners.fire(peer.id, stream, media.remoteMetaFor(link, stream.id));
|
|
290
|
-
else
|
|
291
|
-
earlyStreams.push(stream);
|
|
292
|
-
};
|
|
293
|
-
const failHandshake = (code, flag, message) => {
|
|
294
|
-
const wasReady = link.ready;
|
|
295
|
-
drop(peer, link);
|
|
296
|
-
if (!stopped && !wasReady && !peer[flag]) {
|
|
230
|
+
if (!stopped && !wasReady && error) {
|
|
231
|
+
const flag = error.code === 'ice-failed' ? 'iceFailedReported' : 'authFailedReported';
|
|
232
|
+
if (!peer[flag]) {
|
|
297
233
|
peer[flag] = true;
|
|
298
|
-
errors.fire({ code, peerId: peer.id, message });
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
const reportIceFailed = (message) => failHandshake('ice-failed', 'iceFailedReported', message);
|
|
302
|
-
const reportAuthFailed = (message) => failHandshake('auth-failed', 'authFailedReported', message);
|
|
303
|
-
peer.link = link;
|
|
304
|
-
link.deadline = setTimeout(() => reportIceFailed('Connection handshake timed out'), timeout);
|
|
305
|
-
pc.onconnectionstatechange = () => {
|
|
306
|
-
if (peer.link !== link)
|
|
307
|
-
return;
|
|
308
|
-
if (pc.connectionState === 'failed')
|
|
309
|
-
reportIceFailed('Peer connection failed');
|
|
310
|
-
else if (pc.connectionState === 'closed')
|
|
311
|
-
drop(peer, link);
|
|
312
|
-
else if (pc.connectionState === 'disconnected') {
|
|
313
|
-
link.grace ??= setTimeout(() => drop(peer, link), disconnectGrace);
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
clearTimeout(link.grace);
|
|
317
|
-
delete link.grace;
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
const early = [];
|
|
321
|
-
const earlyRtc = [];
|
|
322
|
-
let earlyBytes = 0;
|
|
323
|
-
const tryPromoteReady = () => {
|
|
324
|
-
if (stopped ||
|
|
325
|
-
peer.link !== link ||
|
|
326
|
-
link.ready ||
|
|
327
|
-
!link.channelsOpen ||
|
|
328
|
-
!link.helloSent ||
|
|
329
|
-
!link.helloVerified) {
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
const reclaimMatch = link.pendingReclaimMatch;
|
|
333
|
-
link.pendingReclaimMatch = null;
|
|
334
|
-
if (reclaimMatch) {
|
|
335
|
-
const oldPeer = peers.get(reclaimMatch.id);
|
|
336
|
-
const oldLink = oldPeer?.link;
|
|
337
|
-
if (oldPeer && oldLink?.reclaimCommit && oldLink.reclaimCommit === reclaimMatch.commit) {
|
|
338
|
-
reclaim.markSuperseded(oldPeer.id);
|
|
339
|
-
oldPeer.advertised = false;
|
|
340
|
-
clearTimeout(oldPeer.retry);
|
|
341
|
-
delete oldPeer.retry;
|
|
342
|
-
drop(oldPeer, oldLink, false, false);
|
|
343
|
-
if (stopped || peer.link !== link)
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
clearTimeout(link.deadline);
|
|
348
|
-
clearTimeout(link.iceFlush);
|
|
349
|
-
delete link.iceFlush;
|
|
350
|
-
link.reclaimCommit = link.remoteReclaimCommit;
|
|
351
|
-
link.userId = link.verifiedUserId;
|
|
352
|
-
link.ready = true;
|
|
353
|
-
peer.failures = 0;
|
|
354
|
-
peer.iceFailedReported = false;
|
|
355
|
-
peer.authFailedReported = false;
|
|
356
|
-
joins.fire(peer.id);
|
|
357
|
-
for (const stream of earlyStreams) {
|
|
358
|
-
if (peer.link !== link || stopped)
|
|
359
|
-
break;
|
|
360
|
-
peerStreamListeners.fire(peer.id, stream, media.remoteMetaFor(link, stream.id));
|
|
361
|
-
}
|
|
362
|
-
earlyStreams.length = 0;
|
|
363
|
-
for (const raw of earlyRtc) {
|
|
364
|
-
if (peer.link !== link || stopped)
|
|
365
|
-
break;
|
|
366
|
-
media.handleRtcControl(peer, link, raw);
|
|
234
|
+
errors.fire({ code: error.code, peerId: peer.id, message: error.message });
|
|
367
235
|
}
|
|
368
|
-
earlyRtc.length = 0;
|
|
369
|
-
for (const [bytes, mode] of early) {
|
|
370
|
-
if (peer.link !== link || stopped)
|
|
371
|
-
break;
|
|
372
|
-
packets.fire(peer.id, bytes, mode);
|
|
373
|
-
}
|
|
374
|
-
early.length = 0;
|
|
375
|
-
// Reconcile local streams (attach newly desired ones, detach any removed mid-handshake).
|
|
376
|
-
if (!stopped && peer.link === link) {
|
|
377
|
-
media.reconcileLinkStreams(peer, link);
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
for (const delivery of ['unreliable', 'reliable']) {
|
|
381
|
-
const channel = channels[delivery];
|
|
382
|
-
channel.binaryType = 'arraybuffer';
|
|
383
|
-
channel.bufferedAmountLowThreshold = Math.floor(bufferLimit[delivery] / 2);
|
|
384
|
-
channel.onbufferedamountlow = () => {
|
|
385
|
-
if (!stopped && peer.link === link && link.ready)
|
|
386
|
-
drains.fire(peer.id, delivery);
|
|
387
|
-
};
|
|
388
|
-
channel.onclose = () => drop(peer, link);
|
|
389
|
-
channel.onerror = () => drop(peer, link);
|
|
390
|
-
channel.onopen = () => {
|
|
391
|
-
if (stopped || peer.link !== link || link.channelsOpen)
|
|
392
|
-
return;
|
|
393
|
-
if (!Object.values(channels).every((c) => c.readyState === 'open'))
|
|
394
|
-
return;
|
|
395
|
-
link.channelsOpen = true;
|
|
396
|
-
void (async () => {
|
|
397
|
-
try {
|
|
398
|
-
const frame = await buildHelloFrame({
|
|
399
|
-
localReclaimCommitPromise: reclaim.localCommitPromise,
|
|
400
|
-
initialTags: media.collectLinkStreamTags(link),
|
|
401
|
-
pendingReclaim: reclaim.getPendingReclaim(),
|
|
402
|
-
identity,
|
|
403
|
-
appId,
|
|
404
|
-
roomName: name,
|
|
405
|
-
self,
|
|
406
|
-
peerId: peer.id,
|
|
407
|
-
pc
|
|
408
|
-
});
|
|
409
|
-
if (stopped || peer.link !== link)
|
|
410
|
-
return;
|
|
411
|
-
if (channels.reliable.readyState !== 'open') {
|
|
412
|
-
drop(peer, link);
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
channels.reliable.send(frame);
|
|
416
|
-
link.helloSent = true;
|
|
417
|
-
tryPromoteReady();
|
|
418
|
-
}
|
|
419
|
-
catch {
|
|
420
|
-
if (!stopped && peer.link === link)
|
|
421
|
-
drop(peer, link);
|
|
422
|
-
}
|
|
423
|
-
})();
|
|
424
|
-
};
|
|
425
|
-
channel.onmessage = ({ data }) => {
|
|
426
|
-
if (stopped || peer.link !== link)
|
|
427
|
-
return;
|
|
428
|
-
if (data === leaveNotice && delivery === 'reliable') {
|
|
429
|
-
peer.advertised = false;
|
|
430
|
-
drop(peer, link);
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
if (typeof data === 'string' && delivery === 'reliable' && data.startsWith(helloPrefix)) {
|
|
434
|
-
if (link.helloReceived) {
|
|
435
|
-
drop(peer, link);
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
link.helloReceived = true;
|
|
439
|
-
const parsedRes = parseHelloFrame(data, self, peer.id);
|
|
440
|
-
if (!parsedRes.ok) {
|
|
441
|
-
reportAuthFailed(parsedRes.error);
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
const { parsed } = parsedRes;
|
|
445
|
-
void verifyHelloFrame(parsed, { appId, roomName: name, self, peerId: peer.id, pc }).then((verified) => {
|
|
446
|
-
if (stopped || peer.link !== link)
|
|
447
|
-
return;
|
|
448
|
-
if (!verified.ok) {
|
|
449
|
-
reportAuthFailed(verified.error);
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
if (parsed.initialStreamTags)
|
|
453
|
-
media.mergeRemoteStreamTags(link, parsed.initialStreamTags);
|
|
454
|
-
link.verifiedUserId = verified.verifiedUserId;
|
|
455
|
-
link.remoteReclaimCommit = parsed.rc;
|
|
456
|
-
link.pendingReclaimMatch = verified.reclaimMatch;
|
|
457
|
-
link.helloVerified = true;
|
|
458
|
-
tryPromoteReady();
|
|
459
|
-
});
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
if (typeof data === 'string' &&
|
|
463
|
-
delivery === 'reliable' &&
|
|
464
|
-
data.startsWith(rtcControlPrefix)) {
|
|
465
|
-
if (link.ready)
|
|
466
|
-
media.handleRtcControl(peer, link, data);
|
|
467
|
-
else if (earlyRtc.length < 16 && data.length <= maxRtcControlBytes)
|
|
468
|
-
earlyRtc.push(data);
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
if (!(data instanceof ArrayBuffer))
|
|
472
|
-
return;
|
|
473
|
-
if (data.byteLength > maxPacket) {
|
|
474
|
-
if (delivery === 'reliable')
|
|
475
|
-
drop(peer, link);
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
const bytes = new Uint8Array(data);
|
|
479
|
-
if (link.ready)
|
|
480
|
-
packets.fire(peer.id, bytes, delivery);
|
|
481
|
-
else if (early.length >= 64 || earlyBytes + bytes.byteLength > 256 * 1024) {
|
|
482
|
-
if (delivery === 'reliable')
|
|
483
|
-
drop(peer, link);
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
early.push([bytes, delivery]);
|
|
487
|
-
earlyBytes += bytes.byteLength;
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
236
|
}
|
|
491
|
-
|
|
237
|
+
void link;
|
|
492
238
|
}
|
|
493
|
-
|
|
239
|
+
function drop(peer, link, flushLeave = false, shouldRetry = true) {
|
|
240
|
+
if (peer.link !== link)
|
|
241
|
+
return;
|
|
242
|
+
delete peer.link;
|
|
243
|
+
const wasReady = link.ready;
|
|
244
|
+
if (link.accepted)
|
|
245
|
+
peer.previous = link.attempt;
|
|
246
|
+
if (peer.earlyIce?.attempt === link.attempt)
|
|
247
|
+
delete peer.earlyIce;
|
|
248
|
+
const endedStreams = link.close({ flushLeave });
|
|
249
|
+
finishDrop(peer, link, endedStreams, wasReady, shouldRetry);
|
|
250
|
+
}
|
|
251
|
+
function negotiate(peer, attempt, remoteOffer) {
|
|
494
252
|
if (stopped || !peer.advertised || !signaling)
|
|
495
253
|
return;
|
|
254
|
+
clearTimeout(peer.retry);
|
|
255
|
+
delete peer.retry;
|
|
496
256
|
let link;
|
|
497
257
|
try {
|
|
498
|
-
link =
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
const earlyCandidates = peer.earlyIce.candidates;
|
|
507
|
-
delete peer.earlyIce;
|
|
508
|
-
applyRemoteCandidates(peer, link, earlyCandidates);
|
|
509
|
-
}
|
|
510
|
-
if (link.pendingCandidates.length > 0) {
|
|
511
|
-
const queued = link.pendingCandidates.splice(0);
|
|
512
|
-
applyRemoteCandidates(peer, link, queued);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
link.accepted = true;
|
|
516
|
-
const description = remoteOffer === undefined ? await pc.createOffer() : await pc.createAnswer();
|
|
517
|
-
if (peer.link !== link)
|
|
518
|
-
return;
|
|
519
|
-
const current = link;
|
|
520
|
-
const extendedGather = options.iceGatheringTimeoutMs === undefined
|
|
521
|
-
? Math.min(10_000, Math.floor(timeout / 2))
|
|
522
|
-
: gatherTimeout;
|
|
523
|
-
await setAndPublishLocalDescription({
|
|
524
|
-
link: current,
|
|
525
|
-
description,
|
|
258
|
+
link = createPeerLink({
|
|
259
|
+
appId,
|
|
260
|
+
roomName: name,
|
|
261
|
+
self,
|
|
262
|
+
peerId: peer.id,
|
|
263
|
+
attempt,
|
|
264
|
+
PeerConnection: PeerConnection,
|
|
265
|
+
rtcConfig,
|
|
526
266
|
useTrickle,
|
|
527
267
|
needsRelay,
|
|
528
268
|
hasTurn,
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
269
|
+
timeoutMs: timeout,
|
|
270
|
+
gatherTimeoutMs: gatherTimeout,
|
|
271
|
+
extendedGatherMs: extendedGather,
|
|
272
|
+
identity,
|
|
273
|
+
localReclaimCommitPromise: reclaim.localCommitPromise,
|
|
274
|
+
getPendingReclaim: reclaim.getPendingReclaim,
|
|
275
|
+
getDesiredStreams: () => desiredStreamsFor(peer.id),
|
|
276
|
+
getStreamTag: (stream) => localStreamTags.get(stream),
|
|
533
277
|
onPublishSdp(kind, sdp) {
|
|
534
|
-
|
|
535
|
-
drop(peer, current);
|
|
278
|
+
return Boolean(signaling?.send(peer.id, { kind, attempt, sdp }));
|
|
536
279
|
},
|
|
537
280
|
onSendIce(candidates) {
|
|
538
281
|
signaling?.send(peer.id, { kind: 'ice', attempt, candidates });
|
|
282
|
+
},
|
|
283
|
+
onReclaim(reclaimMatch) {
|
|
284
|
+
if (stopped || peer.link !== link)
|
|
285
|
+
return false;
|
|
286
|
+
const oldPeer = peers.get(reclaimMatch.id);
|
|
287
|
+
const oldLink = oldPeer?.link;
|
|
288
|
+
if (oldPeer && oldLink?.reclaimCommit && oldLink.reclaimCommit === reclaimMatch.commit) {
|
|
289
|
+
reclaim.markSuperseded(oldPeer.id);
|
|
290
|
+
oldPeer.advertised = false;
|
|
291
|
+
clearTimeout(oldPeer.retry);
|
|
292
|
+
delete oldPeer.retry;
|
|
293
|
+
drop(oldPeer, oldLink, false, false);
|
|
294
|
+
}
|
|
295
|
+
return !stopped && peer.link === link;
|
|
296
|
+
},
|
|
297
|
+
onReady() {
|
|
298
|
+
if (stopped || peer.link !== link)
|
|
299
|
+
return;
|
|
300
|
+
peer.failures = 0;
|
|
301
|
+
peer.iceFailedReported = false;
|
|
302
|
+
peer.authFailedReported = false;
|
|
303
|
+
joins.fire(peer.id);
|
|
304
|
+
},
|
|
305
|
+
onDrop(event) {
|
|
306
|
+
if (peer.link !== link)
|
|
307
|
+
return;
|
|
308
|
+
delete peer.link;
|
|
309
|
+
const wasReady = link.ready;
|
|
310
|
+
if (link.accepted)
|
|
311
|
+
peer.previous = link.attempt;
|
|
312
|
+
if (peer.earlyIce?.attempt === link.attempt)
|
|
313
|
+
delete peer.earlyIce;
|
|
314
|
+
if (event.remoteLeave)
|
|
315
|
+
peer.advertised = false;
|
|
316
|
+
finishDrop(peer, link, event.endedStreams, wasReady, event.shouldRetry, event.error);
|
|
317
|
+
},
|
|
318
|
+
onPacket(bytes, delivery) {
|
|
319
|
+
if (!stopped && peer.link === link)
|
|
320
|
+
packets.fire(peer.id, bytes, delivery);
|
|
321
|
+
},
|
|
322
|
+
onDrain(delivery) {
|
|
323
|
+
if (!stopped && peer.link === link)
|
|
324
|
+
drains.fire(peer.id, delivery);
|
|
325
|
+
},
|
|
326
|
+
onStream(stream, meta) {
|
|
327
|
+
if (!stopped && peer.link === link)
|
|
328
|
+
peerStreamListeners.fire(peer.id, stream, meta);
|
|
329
|
+
},
|
|
330
|
+
onStreamEnd(stream, meta) {
|
|
331
|
+
if (!stopped && peer.link === link)
|
|
332
|
+
peerStreamEndListeners.fire(peer.id, stream, meta);
|
|
333
|
+
},
|
|
334
|
+
onMediaError(message) {
|
|
335
|
+
if (!stopped && peer.link === link) {
|
|
336
|
+
errors.fire({ code: 'media-error', peerId: peer.id, message });
|
|
337
|
+
}
|
|
539
338
|
}
|
|
540
339
|
});
|
|
541
340
|
}
|
|
542
341
|
catch {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
else
|
|
546
|
-
retry(peer);
|
|
342
|
+
retry(peer);
|
|
343
|
+
return;
|
|
547
344
|
}
|
|
345
|
+
peer.link = link;
|
|
346
|
+
let earlyCandidates;
|
|
347
|
+
if (remoteOffer !== undefined && peer.earlyIce?.attempt === attempt) {
|
|
348
|
+
earlyCandidates = peer.earlyIce.candidates;
|
|
349
|
+
delete peer.earlyIce;
|
|
350
|
+
}
|
|
351
|
+
void link.start(remoteOffer, earlyCandidates);
|
|
548
352
|
}
|
|
549
353
|
function discover(peer) {
|
|
550
354
|
if (stopped ||
|
|
@@ -555,7 +359,7 @@ export function joinRoom(name, options) {
|
|
|
555
359
|
peer.retry)
|
|
556
360
|
return;
|
|
557
361
|
if (self < peer.id)
|
|
558
|
-
|
|
362
|
+
negotiate(peer, ++nextAttempt);
|
|
559
363
|
else {
|
|
560
364
|
signaling.send(peer.id, { kind: 'need', previous: peer.previous });
|
|
561
365
|
retry(peer);
|
|
@@ -576,17 +380,8 @@ export function joinRoom(name, options) {
|
|
|
576
380
|
drop(peer, link, false, false);
|
|
577
381
|
discover(peer);
|
|
578
382
|
}
|
|
579
|
-
else
|
|
580
|
-
|
|
581
|
-
link.published &&
|
|
582
|
-
link.pc.signalingState === 'have-local-offer' &&
|
|
583
|
-
link.pc.localDescription?.type === 'offer') {
|
|
584
|
-
if (!signaling?.send(peer.id, {
|
|
585
|
-
kind: 'offer',
|
|
586
|
-
attempt: link.attempt,
|
|
587
|
-
sdp: link.pc.localDescription.sdp
|
|
588
|
-
}))
|
|
589
|
-
drop(peer, link);
|
|
383
|
+
else {
|
|
384
|
+
link.resendOfferIfPending();
|
|
590
385
|
}
|
|
591
386
|
}
|
|
592
387
|
else {
|
|
@@ -604,21 +399,11 @@ export function joinRoom(name, options) {
|
|
|
604
399
|
return;
|
|
605
400
|
if (link)
|
|
606
401
|
drop(peer, link, false, false);
|
|
607
|
-
|
|
402
|
+
negotiate(peer, signal.attempt, prepareRemoteSdp(signal));
|
|
608
403
|
}
|
|
609
404
|
else if (signal.kind === 'ice') {
|
|
610
405
|
if (link && signal.attempt === link.attempt) {
|
|
611
|
-
|
|
612
|
-
if (link.remoteDescApplied) {
|
|
613
|
-
applyRemoteCandidates(peer, link, candidates);
|
|
614
|
-
}
|
|
615
|
-
else {
|
|
616
|
-
for (const item of candidates) {
|
|
617
|
-
if (link.pendingCandidates.length >= maxTrickleCandidates)
|
|
618
|
-
break;
|
|
619
|
-
link.pendingCandidates.push(item);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
406
|
+
link.addRemoteCandidates(prepareRemoteCandidates(signal));
|
|
622
407
|
}
|
|
623
408
|
else {
|
|
624
409
|
const baseline = link?.attempt ?? peer.previous ?? 0;
|
|
@@ -638,25 +423,8 @@ export function joinRoom(name, options) {
|
|
|
638
423
|
}
|
|
639
424
|
}
|
|
640
425
|
}
|
|
641
|
-
else if (signal.kind === 'answer' &&
|
|
642
|
-
|
|
643
|
-
link &&
|
|
644
|
-
!link.answerApplied &&
|
|
645
|
-
link.attempt === signal.attempt &&
|
|
646
|
-
link.pc.signalingState === 'have-local-offer') {
|
|
647
|
-
link.answerApplied = true;
|
|
648
|
-
void link.pc
|
|
649
|
-
.setRemoteDescription({ type: 'answer', sdp: prepareRemoteSdp(signal) })
|
|
650
|
-
.then(() => {
|
|
651
|
-
if (stopped || peer.link !== link)
|
|
652
|
-
return;
|
|
653
|
-
link.remoteDescApplied = true;
|
|
654
|
-
if (link.pendingCandidates.length > 0) {
|
|
655
|
-
const queued = link.pendingCandidates.splice(0);
|
|
656
|
-
applyRemoteCandidates(peer, link, queued);
|
|
657
|
-
}
|
|
658
|
-
})
|
|
659
|
-
.catch(() => drop(peer, link));
|
|
426
|
+
else if (signal.kind === 'answer' && self < id && link && link.attempt === signal.attempt) {
|
|
427
|
+
link.applyAnswer(prepareRemoteSdp(signal));
|
|
660
428
|
}
|
|
661
429
|
}
|
|
662
430
|
signaling = options.signaling({
|
|
@@ -776,25 +544,100 @@ export function joinRoom(name, options) {
|
|
|
776
544
|
onError: errors.add,
|
|
777
545
|
onPeerStream: peerStreamListeners.add,
|
|
778
546
|
onPeerStreamEnd: peerStreamEndListeners.add,
|
|
779
|
-
addStream
|
|
780
|
-
|
|
781
|
-
|
|
547
|
+
addStream(stream, toOrOptions) {
|
|
548
|
+
if (stopped)
|
|
549
|
+
throw new Error('Room is closed');
|
|
550
|
+
if (!stream || typeof stream.getTracks !== 'function')
|
|
551
|
+
throw new TypeError('Expected a MediaStream');
|
|
552
|
+
const { to, tag } = parseStreamTarget(toOrOptions, true);
|
|
553
|
+
if (tag !== undefined)
|
|
554
|
+
localStreamTags.set(stream, tag);
|
|
555
|
+
if (to === undefined) {
|
|
556
|
+
broadcastStreams.add(stream);
|
|
557
|
+
for (const peer of peers.values()) {
|
|
558
|
+
if (peer.link?.ready)
|
|
559
|
+
peer.link.attachStream(stream, true);
|
|
560
|
+
}
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (to === self) {
|
|
564
|
+
if (!isStreamRegistered(stream))
|
|
565
|
+
localStreamTags.delete(stream);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
let set = peerStreams.get(to);
|
|
569
|
+
if (!set) {
|
|
570
|
+
set = new Set();
|
|
571
|
+
peerStreams.set(to, set);
|
|
572
|
+
}
|
|
573
|
+
set.add(stream);
|
|
574
|
+
const link = peers.get(to)?.link;
|
|
575
|
+
if (link?.ready)
|
|
576
|
+
link.attachStream(stream, true);
|
|
577
|
+
},
|
|
578
|
+
removeStream(stream, toOrOptions) {
|
|
579
|
+
const { to } = parseStreamTarget(toOrOptions, false);
|
|
580
|
+
if (stopped || !stream)
|
|
581
|
+
return;
|
|
582
|
+
if (to === undefined) {
|
|
583
|
+
if (!broadcastStreams.delete(stream))
|
|
584
|
+
return;
|
|
585
|
+
if (!isStreamRegistered(stream))
|
|
586
|
+
localStreamTags.delete(stream);
|
|
587
|
+
for (const peer of peers.values()) {
|
|
588
|
+
if (peerStreams.get(peer.id)?.has(stream))
|
|
589
|
+
continue;
|
|
590
|
+
if (peer.link?.ready)
|
|
591
|
+
peer.link.detachStream(stream, true);
|
|
592
|
+
}
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
const set = peerStreams.get(to);
|
|
596
|
+
if (!set?.delete(stream))
|
|
597
|
+
return;
|
|
598
|
+
if (set.size === 0)
|
|
599
|
+
peerStreams.delete(to);
|
|
600
|
+
if (!isStreamRegistered(stream))
|
|
601
|
+
localStreamTags.delete(stream);
|
|
602
|
+
if (broadcastStreams.has(stream))
|
|
603
|
+
return;
|
|
604
|
+
const link = peers.get(to)?.link;
|
|
605
|
+
if (link?.ready)
|
|
606
|
+
link.detachStream(stream, true);
|
|
607
|
+
},
|
|
608
|
+
async replaceStreamTrack(stream, oldTrack, newTrack) {
|
|
609
|
+
if (stopped)
|
|
610
|
+
throw new Error('Room is closed');
|
|
611
|
+
if (!stream || typeof stream.getTracks !== 'function')
|
|
612
|
+
throw new TypeError('Expected a MediaStream');
|
|
613
|
+
if (!oldTrack ||
|
|
614
|
+
typeof oldTrack.kind !== 'string' ||
|
|
615
|
+
!newTrack ||
|
|
616
|
+
typeof newTrack.kind !== 'string' ||
|
|
617
|
+
oldTrack.kind !== newTrack.kind) {
|
|
618
|
+
throw new TypeError('Expected matching-kind MediaStreamTrack instances');
|
|
619
|
+
}
|
|
620
|
+
if (!isStreamRegistered(stream)) {
|
|
621
|
+
throw new Error('Stream is not attached to this room');
|
|
622
|
+
}
|
|
623
|
+
if (oldTrack === newTrack)
|
|
624
|
+
return;
|
|
625
|
+
if (stream.getTracks().includes(oldTrack))
|
|
626
|
+
stream.removeTrack(oldTrack);
|
|
627
|
+
if (!stream.getTracks().includes(newTrack))
|
|
628
|
+
stream.addTrack(newTrack);
|
|
629
|
+
const ops = [];
|
|
630
|
+
for (const peer of peers.values()) {
|
|
631
|
+
if (peer.link)
|
|
632
|
+
ops.push(peer.link.replaceTrack(stream, oldTrack, newTrack));
|
|
633
|
+
}
|
|
634
|
+
if (ops.length > 0)
|
|
635
|
+
await Promise.all(ops);
|
|
636
|
+
},
|
|
782
637
|
async getStats(peerId) {
|
|
783
638
|
if (stopped || peerId === self)
|
|
784
639
|
return null;
|
|
785
|
-
|
|
786
|
-
const link = peer?.link;
|
|
787
|
-
if (!peer || !link?.ready)
|
|
788
|
-
return null;
|
|
789
|
-
try {
|
|
790
|
-
const report = await link.pc.getStats();
|
|
791
|
-
if (stopped || peer.link !== link || !link.ready)
|
|
792
|
-
return null;
|
|
793
|
-
return parsePeerStats(report, link.channels.unreliable.bufferedAmount, link.channels.reliable.bufferedAmount);
|
|
794
|
-
}
|
|
795
|
-
catch {
|
|
796
|
-
return null;
|
|
797
|
-
}
|
|
640
|
+
return (await peers.get(peerId)?.link?.getStats()) ?? null;
|
|
798
641
|
},
|
|
799
642
|
send(bytes, { to, delivery = 'unreliable' } = {}) {
|
|
800
643
|
if (stopped)
|
|
@@ -807,28 +650,7 @@ export function joinRoom(name, options) {
|
|
|
807
650
|
const targets = to === undefined ? connected() : [to];
|
|
808
651
|
for (const id of targets) {
|
|
809
652
|
const link = peers.get(id)?.link;
|
|
810
|
-
|
|
811
|
-
if (!link?.ready || channel?.readyState !== 'open')
|
|
812
|
-
result.set(id, 'unavailable');
|
|
813
|
-
else if (bytes.byteLength > Math.min(maxPacket, link.pc.sctp?.maxMessageSize || Infinity))
|
|
814
|
-
result.set(id, 'too-large');
|
|
815
|
-
else if (channel.bufferedAmount + bytes.byteLength > bufferLimit[delivery])
|
|
816
|
-
result.set(id, 'busy');
|
|
817
|
-
else {
|
|
818
|
-
try {
|
|
819
|
-
// Copy shared memory views to a browser-supported non-shared buffer.
|
|
820
|
-
channel.send(bytes.buffer instanceof ArrayBuffer
|
|
821
|
-
? new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
|
822
|
-
: Uint8Array.from(bytes));
|
|
823
|
-
result.set(id, 'accepted');
|
|
824
|
-
}
|
|
825
|
-
catch (error) {
|
|
826
|
-
const isOpError = ((typeof DOMException === 'function' && error instanceof DOMException) ||
|
|
827
|
-
error instanceof Error) &&
|
|
828
|
-
error.name === 'OperationError';
|
|
829
|
-
result.set(id, isOpError ? 'busy' : 'unavailable');
|
|
830
|
-
}
|
|
831
|
-
}
|
|
653
|
+
result.set(id, link ? link.send(bytes, delivery) : 'unavailable');
|
|
832
654
|
}
|
|
833
655
|
return result;
|
|
834
656
|
},
|
|
@@ -858,7 +680,9 @@ export function joinRoom(name, options) {
|
|
|
858
680
|
}
|
|
859
681
|
peers.clear();
|
|
860
682
|
rejectedFull.clear();
|
|
861
|
-
|
|
683
|
+
broadcastStreams.clear();
|
|
684
|
+
peerStreams.clear();
|
|
685
|
+
localStreamTags.clear();
|
|
862
686
|
if (!wasClosed)
|
|
863
687
|
status.fire('closed');
|
|
864
688
|
for (const group of [
|
|
@@ -886,7 +710,20 @@ export function joinRoom(name, options) {
|
|
|
886
710
|
closeHooks.delete(fn);
|
|
887
711
|
};
|
|
888
712
|
},
|
|
889
|
-
getRemoteStreams
|
|
713
|
+
getRemoteStreams() {
|
|
714
|
+
const out = [];
|
|
715
|
+
if (stopped)
|
|
716
|
+
return out;
|
|
717
|
+
for (const peer of peers.values()) {
|
|
718
|
+
const link = peer.link;
|
|
719
|
+
if (!link?.ready)
|
|
720
|
+
continue;
|
|
721
|
+
for (const [stream, meta] of link.getRemoteStreams()) {
|
|
722
|
+
out.push([peer.id, stream, meta]);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return out;
|
|
726
|
+
}
|
|
890
727
|
});
|
|
891
728
|
return room;
|
|
892
729
|
}
|