@netless/forge-rtm 1.0.8 → 1.1.0-beta.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/dist/RTM_2_1.d.ts +6 -0
- package/dist/RTM_2_1.d.ts.map +1 -1
- package/dist/RTM_2_2.d.ts +7 -1
- package/dist/RTM_2_2.d.ts.map +1 -1
- package/dist/rtm-provider.esm.js +128 -1
- package/dist/rtm-provider.esm.js.map +3 -3
- package/dist/rtm-provider.js +128 -1
- package/dist/rtm-provider.js.map +3 -3
- package/package.json +2 -2
package/dist/RTM_2_1.d.ts
CHANGED
|
@@ -13,10 +13,13 @@ export declare class RTMProvider_2_1 extends EventEmitter<SocketProviderEvent> i
|
|
|
13
13
|
private rtmTimestamp;
|
|
14
14
|
private animationStartTimestamp?;
|
|
15
15
|
private animationId?;
|
|
16
|
+
private cachedWritable;
|
|
17
|
+
private isInitialized;
|
|
16
18
|
get calibrationTimestamp(): number;
|
|
17
19
|
constructor(rtmClient: RTMClient);
|
|
18
20
|
private roomChannel;
|
|
19
21
|
private userChannel;
|
|
22
|
+
private writableChannel;
|
|
20
23
|
/**
|
|
21
24
|
* 重新订阅频道
|
|
22
25
|
*/
|
|
@@ -26,11 +29,14 @@ export declare class RTMProvider_2_1 extends EventEmitter<SocketProviderEvent> i
|
|
|
26
29
|
private isForgeRoomChannel;
|
|
27
30
|
private handleRtmMessage;
|
|
28
31
|
private calibrateAnimate;
|
|
32
|
+
private handleStorageEvent;
|
|
29
33
|
private handleStatus;
|
|
30
34
|
private handlePresence;
|
|
31
35
|
private receiveChunkMessage;
|
|
32
36
|
publish(buf: Uint8Array, customType: string, target?: string): void;
|
|
33
37
|
userList(): Promise<Set<string>>;
|
|
34
38
|
historyMessage(_begin: number, _end: number): Promise<null>;
|
|
39
|
+
setUserWritable(writable: boolean, userId?: string): Promise<void>;
|
|
40
|
+
getUserWritable(userId?: string): Promise<boolean>;
|
|
35
41
|
}
|
|
36
42
|
//# sourceMappingURL=RTM_2_1.d.ts.map
|
package/dist/RTM_2_1.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RTM_2_1.d.ts","sourceRoot":"","sources":["../src/RTM_2_1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAO,MAAM,qBAAqB,CAAC;AAC/E,OAAO,YAAY,MAAM,eAAe,CAAC;AAIzC,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,WAAW,CAAC;AAItD,qBAAa,eAAgB,SAAQ,YAAY,CAAC,mBAAmB,CAAE,YAAW,cAAc;IAE9F,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,MAAM,CAAU;IAExB,OAAO,CAAC,gBAAgB,CAAa;IACrC,OAAO,CAAC,eAAe,CAAkD;IACzE,OAAO,CAAC,cAAc,CAA8B;IAEpD,OAAO,CAAC,UAAU,CAAa;IAE/B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,uBAAuB,CAAC,CAAS;IACzC,OAAO,CAAC,WAAW,CAAC,CAAS;
|
|
1
|
+
{"version":3,"file":"RTM_2_1.d.ts","sourceRoot":"","sources":["../src/RTM_2_1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAO,MAAM,qBAAqB,CAAC;AAC/E,OAAO,YAAY,MAAM,eAAe,CAAC;AAIzC,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,WAAW,CAAC;AAItD,qBAAa,eAAgB,SAAQ,YAAY,CAAC,mBAAmB,CAAE,YAAW,cAAc;IAE9F,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,MAAM,CAAU;IAExB,OAAO,CAAC,gBAAgB,CAAa;IACrC,OAAO,CAAC,eAAe,CAAkD;IACzE,OAAO,CAA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-1,6 +1,6 @@
|
|
|
1
1
|
import { SocketProvider, SocketProviderEvent } from '@netless/forge-room';
|
|
2
2
|
import EventEmitter from 'eventemitter3';
|
|
3
|
-
import
|
|
3
|
+
import { RTMClient } from 'agora-rtm';
|
|
4
4
|
import type { HistoryMessage } from '@netless/forge-room';
|
|
5
5
|
export declare class RTMProvider_2_2 extends EventEmitter<SocketProviderEvent> implements SocketProvider {
|
|
6
6
|
private rtmClient;
|
|
@@ -15,9 +15,12 @@ export declare class RTMProvider_2_2 extends EventEmitter<SocketProviderEvent> i
|
|
|
15
15
|
private rtmTimestamp;
|
|
16
16
|
private animationStartTimestamp?;
|
|
17
17
|
private animationId?;
|
|
18
|
+
private cachedWritable;
|
|
19
|
+
private isInitialized;
|
|
18
20
|
get calibrationTimestamp(): number;
|
|
19
21
|
constructor(rtmClient: RTMClient);
|
|
20
22
|
private roomChannel;
|
|
23
|
+
private writableChannel;
|
|
21
24
|
private userChannel;
|
|
22
25
|
initialize(roomId: string, userId: string): Promise<void>;
|
|
23
26
|
/**
|
|
@@ -28,6 +31,7 @@ export declare class RTMProvider_2_2 extends EventEmitter<SocketProviderEvent> i
|
|
|
28
31
|
private isForgeRoomChannel;
|
|
29
32
|
private handleRtmMessage;
|
|
30
33
|
private calibrateAnimate;
|
|
34
|
+
private handleStorageEvent;
|
|
31
35
|
private handleStatus;
|
|
32
36
|
private handlePresence;
|
|
33
37
|
private receiveChunkMessage;
|
|
@@ -35,5 +39,7 @@ export declare class RTMProvider_2_2 extends EventEmitter<SocketProviderEvent> i
|
|
|
35
39
|
userList(): Promise<Set<string>>;
|
|
36
40
|
private fetchHistoryMessage;
|
|
37
41
|
historyMessage(begin: number, end: number): Promise<HistoryMessage[] | null>;
|
|
42
|
+
setUserWritable(writable: boolean, userId?: string): Promise<void>;
|
|
43
|
+
getUserWritable(userId?: string): Promise<boolean>;
|
|
38
44
|
}
|
|
39
45
|
//# sourceMappingURL=RTM_2_2.d.ts.map
|
package/dist/RTM_2_2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RTM_2_2.d.ts","sourceRoot":"","sources":["../src/RTM_2_2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAO,MAAM,qBAAqB,CAAC;AAC/E,OAAO,YAAY,MAAM,eAAe,CAAC;AAKzC,OAAO,
|
|
1
|
+
{"version":3,"file":"RTM_2_2.d.ts","sourceRoot":"","sources":["../src/RTM_2_2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAO,MAAM,qBAAqB,CAAC;AAC/E,OAAO,YAAY,MAAM,eAAe,CAAC;AAKzC,OAAO,EAAE,SAAS,EAAa,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,qBAAa,eAAgB,SAAQ,YAAY,CAAC,mBAAmB,CAAE,YAAW,cAAc;IAE9F,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,MAAM,CAAU;IAExB,OAAO,CAAC,gBAAgB,CAAa;IAErC,OAAO,CAAC,eAAe,CAAkD;IACzE,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,2BAA2B,CAAa;IAEhD,OAAO,CAAC,UAAU,CAAa;IAE/B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,uBAAuB,CAAC,CAAS;IACzC,OAAO,CAAC,WAAW,CAAC,CAAS;IAE7B,OAAO,CAAC,cAAc,CAAmC;IACzD,OAAO,CAAC,aAAa,CAAkB;IAEvC,IAAW,oBAAoB,IAAI,MAAM,CAExC;gBAEkB,SAAS,EAAE,SAAS;IAKvC,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,WAAW;IAON,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsDtE;;OAEG;IACU,WAAW;IAeX,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAYrC,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,gBAAgB,CAoBtB;IAEF,OAAO,CAAC,gBAAgB,CAQtB;IAEF,OAAO,CAAC,kBAAkB,CAWxB;IAEF,OAAO,CAAC,YAAY,CA0BlB;IAEF,OAAO,CAAC,cAAc,CAYpB;IAEF,OAAO,CAAC,mBAAmB;IAuBpB,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAE,MAAW;IAgC1D,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAwB/B,mBAAmB;IAsDpB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC;IAY5E,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYlE,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAehE"}
|
package/dist/rtm-provider.esm.js
CHANGED
|
@@ -125,6 +125,8 @@ var RTMProvider_2_1 = class extends EventEmitter {
|
|
|
125
125
|
_defineProperty2(this, "rtmTimestamp", 0);
|
|
126
126
|
_defineProperty2(this, "animationStartTimestamp", void 0);
|
|
127
127
|
_defineProperty2(this, "animationId", void 0);
|
|
128
|
+
_defineProperty2(this, "cachedWritable", /* @__PURE__ */ new Map());
|
|
129
|
+
_defineProperty2(this, "isInitialized", false);
|
|
128
130
|
_defineProperty2(this, "handleRtmMessage", (evt) => {
|
|
129
131
|
try {
|
|
130
132
|
const isRoomChannel = evt.channelName.indexOf("_u_") < 0;
|
|
@@ -155,6 +157,17 @@ var RTMProvider_2_1 = class extends EventEmitter {
|
|
|
155
157
|
this.animationId = requestAnimationFrame(this.calibrateAnimate);
|
|
156
158
|
}
|
|
157
159
|
});
|
|
160
|
+
_defineProperty2(this, "handleStorageEvent", (storageData) => {
|
|
161
|
+
if (storageData.channelName === this.writableChannel()) {
|
|
162
|
+
const writableStates = {};
|
|
163
|
+
const metadata = storageData.data.metadata;
|
|
164
|
+
for (const userId in metadata) {
|
|
165
|
+
const value = metadata[userId].value;
|
|
166
|
+
writableStates[userId] = value === "true";
|
|
167
|
+
}
|
|
168
|
+
this.emit("writableChanged", writableStates);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
158
171
|
_defineProperty2(this, "handleStatus", (connectionStatus) => {
|
|
159
172
|
log("rtm status update", {
|
|
160
173
|
state: connectionStatus.state,
|
|
@@ -200,6 +213,9 @@ var RTMProvider_2_1 = class extends EventEmitter {
|
|
|
200
213
|
}
|
|
201
214
|
return `${this.roomChannel()}_u_${userId}`;
|
|
202
215
|
}
|
|
216
|
+
writableChannel() {
|
|
217
|
+
return "userWritable";
|
|
218
|
+
}
|
|
203
219
|
/**
|
|
204
220
|
* 重新订阅频道
|
|
205
221
|
*/
|
|
@@ -207,6 +223,9 @@ var RTMProvider_2_1 = class extends EventEmitter {
|
|
|
207
223
|
try {
|
|
208
224
|
await this.rtmClient.subscribe(this.roomChannel());
|
|
209
225
|
await this.rtmClient.subscribe(this.userChannel(this.userId));
|
|
226
|
+
await this.rtmClient.subscribe(this.writableChannel(), {
|
|
227
|
+
withMetadata: true
|
|
228
|
+
});
|
|
210
229
|
} catch (error) {
|
|
211
230
|
this.emit("error", `rtm subscribe fail, ${error}`);
|
|
212
231
|
log("rtm subscribe fail", {
|
|
@@ -221,9 +240,13 @@ var RTMProvider_2_1 = class extends EventEmitter {
|
|
|
221
240
|
this.rtmClient.addEventListener("message", this.handleRtmMessage);
|
|
222
241
|
this.rtmClient.addEventListener("presence", this.handlePresence);
|
|
223
242
|
this.rtmClient.addEventListener("status", this.handleStatus);
|
|
243
|
+
this.rtmClient.addEventListener("storage", this.handleStorageEvent);
|
|
224
244
|
try {
|
|
225
245
|
await this.rtmClient.subscribe(this.roomChannel());
|
|
226
246
|
await this.rtmClient.subscribe(this.userChannel(this.userId));
|
|
247
|
+
await this.rtmClient.subscribe(this.writableChannel(), {
|
|
248
|
+
withMetadata: true
|
|
249
|
+
});
|
|
227
250
|
} catch (error) {
|
|
228
251
|
this.emit("error", `rtm subscribe fail, ${error}`);
|
|
229
252
|
log("rtm subscribe fail", {
|
|
@@ -231,6 +254,18 @@ var RTMProvider_2_1 = class extends EventEmitter {
|
|
|
231
254
|
}, "error");
|
|
232
255
|
throw error;
|
|
233
256
|
}
|
|
257
|
+
this.isInitialized = true;
|
|
258
|
+
if (this.cachedWritable.size > 0) {
|
|
259
|
+
const writableData = Array.from(this.cachedWritable.entries()).map((_ref) => {
|
|
260
|
+
let [userId2, writable] = _ref;
|
|
261
|
+
return {
|
|
262
|
+
key: userId2,
|
|
263
|
+
value: writable ? "true" : "false"
|
|
264
|
+
};
|
|
265
|
+
});
|
|
266
|
+
await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), "MESSAGE", writableData);
|
|
267
|
+
this.cachedWritable.clear();
|
|
268
|
+
}
|
|
234
269
|
this.intervalId = setInterval(() => {
|
|
235
270
|
const msg = this.cachedMessages.shift();
|
|
236
271
|
if (msg) {
|
|
@@ -250,9 +285,11 @@ var RTMProvider_2_1 = class extends EventEmitter {
|
|
|
250
285
|
async dispose() {
|
|
251
286
|
this.rtmClient.removeEventListener("message", this.handleRtmMessage);
|
|
252
287
|
this.rtmClient.removeEventListener("presence", this.handlePresence);
|
|
288
|
+
this.rtmClient.removeEventListener("storage", this.handleStorageEvent);
|
|
253
289
|
this.rtmClient.removeEventListener("status", this.handleStatus);
|
|
254
290
|
await this.rtmClient.unsubscribe(this.roomChannel());
|
|
255
291
|
await this.rtmClient.unsubscribe(this.userChannel(this.userId));
|
|
292
|
+
await this.rtmClient.unsubscribe(this.writableChannel());
|
|
256
293
|
window.clearInterval(this.intervalId);
|
|
257
294
|
}
|
|
258
295
|
isForgeRoomChannel(channel) {
|
|
@@ -336,6 +373,31 @@ var RTMProvider_2_1 = class extends EventEmitter {
|
|
|
336
373
|
async historyMessage(_begin, _end) {
|
|
337
374
|
return null;
|
|
338
375
|
}
|
|
376
|
+
async setUserWritable(writable, userId) {
|
|
377
|
+
const targetUserId = userId || this.userId;
|
|
378
|
+
if (!this.isInitialized) {
|
|
379
|
+
this.cachedWritable.set(targetUserId, writable);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), "MESSAGE", [{
|
|
383
|
+
key: targetUserId,
|
|
384
|
+
value: writable ? "true" : "false"
|
|
385
|
+
}]);
|
|
386
|
+
}
|
|
387
|
+
async getUserWritable(userId) {
|
|
388
|
+
const targetUserId = userId || this.userId;
|
|
389
|
+
try {
|
|
390
|
+
const channelMeta = await this.rtmClient.storage.getChannelMetadata(this.writableChannel(), "MESSAGE");
|
|
391
|
+
const value = channelMeta.metadata[targetUserId]?.value;
|
|
392
|
+
return value === "true";
|
|
393
|
+
} catch (error) {
|
|
394
|
+
log("getUserWritable failed", {
|
|
395
|
+
error: error.toString(),
|
|
396
|
+
userId: targetUserId
|
|
397
|
+
}, "warn");
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
339
401
|
};
|
|
340
402
|
|
|
341
403
|
// src/RTM_2_2.ts
|
|
@@ -377,6 +439,8 @@ var RTMProvider_2_2 = class extends EventEmitter2 {
|
|
|
377
439
|
_defineProperty3(this, "rtmTimestamp", 0);
|
|
378
440
|
_defineProperty3(this, "animationStartTimestamp", void 0);
|
|
379
441
|
_defineProperty3(this, "animationId", void 0);
|
|
442
|
+
_defineProperty3(this, "cachedWritable", /* @__PURE__ */ new Map());
|
|
443
|
+
_defineProperty3(this, "isInitialized", false);
|
|
380
444
|
_defineProperty3(this, "handleRtmMessage", (evt) => {
|
|
381
445
|
try {
|
|
382
446
|
const isRoomChannel = evt.channelName.indexOf("_u_") < 0;
|
|
@@ -407,6 +471,17 @@ var RTMProvider_2_2 = class extends EventEmitter2 {
|
|
|
407
471
|
this.animationId = requestAnimationFrame(this.calibrateAnimate);
|
|
408
472
|
}
|
|
409
473
|
});
|
|
474
|
+
_defineProperty3(this, "handleStorageEvent", (storageData) => {
|
|
475
|
+
if (storageData.channelName === this.writableChannel()) {
|
|
476
|
+
const writableStates = {};
|
|
477
|
+
const metadata = storageData.data.metadata;
|
|
478
|
+
for (const userId in metadata) {
|
|
479
|
+
const value = metadata[userId].value;
|
|
480
|
+
writableStates[userId] = value === "true";
|
|
481
|
+
}
|
|
482
|
+
this.emit("writableChanged", writableStates);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
410
485
|
_defineProperty3(this, "handleStatus", (connectionStatus) => {
|
|
411
486
|
log2("rtm status update", {
|
|
412
487
|
state: connectionStatus.state,
|
|
@@ -451,6 +526,9 @@ var RTMProvider_2_2 = class extends EventEmitter2 {
|
|
|
451
526
|
roomChannel() {
|
|
452
527
|
return `r_${this.roomId}`;
|
|
453
528
|
}
|
|
529
|
+
writableChannel() {
|
|
530
|
+
return `${this.roomChannel()}_uw`;
|
|
531
|
+
}
|
|
454
532
|
userChannel(userId) {
|
|
455
533
|
if (userId.length > 16) {
|
|
456
534
|
userId = `${cyrb53(userId)}`;
|
|
@@ -464,9 +542,15 @@ var RTMProvider_2_2 = class extends EventEmitter2 {
|
|
|
464
542
|
this.rtmClient.addEventListener("message", this.handleRtmMessage);
|
|
465
543
|
this.rtmClient.addEventListener("presence", this.handlePresence);
|
|
466
544
|
this.rtmClient.addEventListener("status", this.handleStatus);
|
|
545
|
+
this.rtmClient.addEventListener("storage", this.handleStorageEvent);
|
|
467
546
|
try {
|
|
468
|
-
await this.rtmClient.subscribe(this.roomChannel()
|
|
547
|
+
await this.rtmClient.subscribe(this.roomChannel(), {
|
|
548
|
+
withPresence: true
|
|
549
|
+
});
|
|
469
550
|
await this.rtmClient.subscribe(this.userChannel(this.userId));
|
|
551
|
+
await this.rtmClient.subscribe(this.writableChannel(), {
|
|
552
|
+
withMetadata: true
|
|
553
|
+
});
|
|
470
554
|
} catch (error) {
|
|
471
555
|
this.emit("error", `rtm subscribe fail, ${error}`);
|
|
472
556
|
log2("rtm subscribe fail", {
|
|
@@ -492,6 +576,18 @@ var RTMProvider_2_2 = class extends EventEmitter2 {
|
|
|
492
576
|
});
|
|
493
577
|
}
|
|
494
578
|
}, 32);
|
|
579
|
+
this.isInitialized = true;
|
|
580
|
+
if (this.cachedWritable.size > 0) {
|
|
581
|
+
const writableData = Array.from(this.cachedWritable.entries()).map((_ref) => {
|
|
582
|
+
let [userId2, writable] = _ref;
|
|
583
|
+
return {
|
|
584
|
+
key: userId2,
|
|
585
|
+
value: writable ? "true" : "false"
|
|
586
|
+
};
|
|
587
|
+
});
|
|
588
|
+
await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), "MESSAGE", writableData);
|
|
589
|
+
this.cachedWritable.clear();
|
|
590
|
+
}
|
|
495
591
|
}
|
|
496
592
|
/**
|
|
497
593
|
* 重新订阅频道
|
|
@@ -500,6 +596,9 @@ var RTMProvider_2_2 = class extends EventEmitter2 {
|
|
|
500
596
|
try {
|
|
501
597
|
await this.rtmClient.subscribe(this.roomChannel());
|
|
502
598
|
await this.rtmClient.subscribe(this.userChannel(this.userId));
|
|
599
|
+
await this.rtmClient.subscribe(this.writableChannel(), {
|
|
600
|
+
withMetadata: true
|
|
601
|
+
});
|
|
503
602
|
} catch (error) {
|
|
504
603
|
this.emit("error", `rtm subscribe fail, ${error}`);
|
|
505
604
|
log2("rtm subscribe fail", {
|
|
@@ -510,9 +609,11 @@ var RTMProvider_2_2 = class extends EventEmitter2 {
|
|
|
510
609
|
async dispose() {
|
|
511
610
|
this.rtmClient.removeEventListener("message", this.handleRtmMessage);
|
|
512
611
|
this.rtmClient.removeEventListener("presence", this.handlePresence);
|
|
612
|
+
this.rtmClient.removeEventListener("storage", this.handleStorageEvent);
|
|
513
613
|
this.rtmClient.removeEventListener("status", this.handleStatus);
|
|
514
614
|
await this.rtmClient.unsubscribe(this.roomChannel());
|
|
515
615
|
await this.rtmClient.unsubscribe(this.userChannel(this.userId));
|
|
616
|
+
await this.rtmClient.unsubscribe(this.writableChannel());
|
|
516
617
|
window.clearInterval(this.intervalId);
|
|
517
618
|
}
|
|
518
619
|
isForgeRoomChannel(channel) {
|
|
@@ -658,6 +759,32 @@ var RTMProvider_2_2 = class extends EventEmitter2 {
|
|
|
658
759
|
return null;
|
|
659
760
|
}
|
|
660
761
|
}
|
|
762
|
+
async setUserWritable(writable, userId) {
|
|
763
|
+
const targetUserId = userId || this.userId;
|
|
764
|
+
if (!this.isInitialized) {
|
|
765
|
+
this.cachedWritable.set(targetUserId, writable);
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), "MESSAGE", [{
|
|
769
|
+
key: targetUserId,
|
|
770
|
+
value: writable ? "true" : "false"
|
|
771
|
+
}]);
|
|
772
|
+
}
|
|
773
|
+
async getUserWritable(userId) {
|
|
774
|
+
const targetUserId = userId || this.userId;
|
|
775
|
+
try {
|
|
776
|
+
const channelMeta = await this.rtmClient.storage.getChannelMetadata(this.writableChannel(), "MESSAGE");
|
|
777
|
+
const value = channelMeta.metadata[targetUserId]?.value;
|
|
778
|
+
return value === "true";
|
|
779
|
+
} catch (error) {
|
|
780
|
+
log2("getUserWritable failed", {
|
|
781
|
+
error: error.toString(),
|
|
782
|
+
userId: targetUserId,
|
|
783
|
+
rtm: "2.2"
|
|
784
|
+
}, "warn");
|
|
785
|
+
return true;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
661
788
|
};
|
|
662
789
|
export {
|
|
663
790
|
RTMProvider_2_1,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/RTM_2_1.ts", "../src/utils.ts", "../src/ChunkedUpdateMessage.ts", "../src/RTM_2_2.ts"],
|
|
4
|
-
"sourcesContent": ["function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nimport { log } from '@netless/forge-room';\nimport EventEmitter from 'eventemitter3';\nimport { v4 as uuidv4 } from 'uuid';\nimport { cyrb53 } from './utils';\nimport { ChunkedUpdateMessage } from './ChunkedUpdateMessage';\nexport class RTMProvider_2_1 extends EventEmitter {\n get calibrationTimestamp() {\n return this.rtmTimestamp + this.deviation;\n }\n constructor(rtmClient) {\n super();\n _defineProperty(this, \"rtmClient\", void 0);\n _defineProperty(this, \"roomId\", void 0);\n _defineProperty(this, \"userId\", void 0);\n _defineProperty(this, \"reconnectTimeout\", null);\n _defineProperty(this, \"chunkedMessages\", new Map());\n _defineProperty(this, \"cachedMessages\", []);\n _defineProperty(this, \"intervalId\", null);\n _defineProperty(this, \"deviation\", 0);\n _defineProperty(this, \"rtmTimestamp\", 0);\n _defineProperty(this, \"animationStartTimestamp\", void 0);\n _defineProperty(this, \"animationId\", void 0);\n _defineProperty(this, \"handleRtmMessage\", evt => {\n try {\n const isRoomChannel = evt.channelName.indexOf('_u_') < 0;\n if (!(evt.message instanceof Uint8Array) || !this.isForgeRoomChannel(evt.channelName)) {\n return;\n }\n if (this.animationId) {\n cancelAnimationFrame(this.animationId);\n this.animationStartTimestamp = undefined;\n this.animationId = undefined;\n this.deviation = 0;\n }\n this.rtmTimestamp = evt.timestamp || Date.now();\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n // console.log(\"rtm timestamp\", evt.timestamp, \"calibrationTimestamp\", this.calibrationTimestamp);\n this.receiveChunkMessage(ChunkedUpdateMessage.fromBuffer(evt.message, '', evt.customType), evt.publisher, isRoomChannel);\n } catch (error) {\n log('rtm handle message error', {\n error: error.toString()\n }, 'error');\n }\n });\n _defineProperty(this, \"calibrateAnimate\", timestamp => {\n if (this.animationStartTimestamp === undefined) {\n this.animationStartTimestamp = timestamp;\n }\n this.deviation = timestamp - this.animationStartTimestamp;\n if (this.animationId) {\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n }\n });\n _defineProperty(this, \"handleStatus\", connectionStatus => {\n log('rtm status update', {\n state: connectionStatus.state,\n reason: connectionStatus.reason\n });\n if (connectionStatus.state === 'RECONNECTING' && this.reconnectTimeout === null) {\n this.emit('connectionStatusChange', 'RECONNECTING');\n this.reconnectTimeout = window.setTimeout(() => {\n this.emit('error', 'reconnecting timeout');\n this.emit('connectionStatusChange', 'DISCONNECTED');\n }, 30 * 1000);\n } else if (connectionStatus.state === 'CONNECTED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('connectionStatusChange', 'CONNECTED');\n } else if (connectionStatus.state === 'FAILED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('error', `rtm connection failed, ${connectionStatus.reason}`);\n this.emit('connectionStatusChange', 'DISCONNECTED');\n } else if (connectionStatus.state === 'CONNECTING') {\n this.emit('connectionStatusChange', 'CONNECTING');\n }\n });\n _defineProperty(this, \"handlePresence\", evt => {\n if (evt.channelName === this.roomChannel()) {\n if (evt.eventType === 'REMOTE_JOIN') {\n this.emit('userJoin', evt.publisher);\n } else if (evt.eventType === 'REMOTE_LEAVE') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'REMOTE_TIMEOUT') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'INTERVAL') {\n // evt.interval.join.users\n }\n }\n });\n this.rtmClient = rtmClient;\n }\n roomChannel() {\n return `r_${this.roomId}`;\n }\n userChannel(userId) {\n if (userId.length > 16) {\n userId = `${cyrb53(userId)}`;\n }\n return `${this.roomChannel()}_u_${userId}`;\n }\n\n /**\n * \u91CD\u65B0\u8BA2\u9605\u9891\u9053\n */\n async resubscribe() {\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n }\n }\n async initialize(roomId, userId) {\n window.clearInterval(this.intervalId);\n this.roomId = roomId;\n this.userId = userId;\n this.rtmClient.addEventListener('message', this.handleRtmMessage);\n this.rtmClient.addEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.addEventListener('status', this.handleStatus);\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n throw error;\n }\n this.intervalId = setInterval(() => {\n const msg = this.cachedMessages.shift();\n if (msg) {\n const channel = msg.target ? this.userChannel(msg.target) : this.roomChannel();\n this.rtmClient.publish(channel, msg.buffer, {\n customType: msg.customType\n }).catch(error => {\n log('rtm publish failed', {\n channel,\n code: error.code\n }, 'warn');\n this.emit('error', `rtm publish fail, ${error}`);\n });\n }\n }, 32);\n }\n async dispose() {\n this.rtmClient.removeEventListener('message', this.handleRtmMessage);\n this.rtmClient.removeEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.removeEventListener('status', this.handleStatus);\n await this.rtmClient.unsubscribe(this.roomChannel());\n await this.rtmClient.unsubscribe(this.userChannel(this.userId));\n window.clearInterval(this.intervalId);\n }\n isForgeRoomChannel(channel) {\n return channel === this.roomChannel() || channel === this.userChannel(this.userId);\n }\n receiveChunkMessage(msg, publisher, isRoomChannel) {\n if (msg.length === 1) {\n this.emit('message', msg.buf, publisher, msg.customType, isRoomChannel);\n return;\n }\n const chunks = this.chunkedMessages.get(msg.session) || [];\n chunks.push(msg);\n if (chunks.length === msg.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n this.emit('message', buffer, publisher, msg.customType, isRoomChannel);\n this.chunkedMessages.delete(msg.session);\n } else {\n this.chunkedMessages.set(msg.session, chunks);\n }\n }\n publish(buf, customType) {\n let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';\n const chunkStep = 24;\n const session = uuidv4();\n // \u6D88\u606F\u5305\u4F53\u79EF, \u5355\u4F4D kb\n const size = buf.length * Uint8Array.BYTES_PER_ELEMENT / 1024;\n if (size < chunkStep) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf,\n length: 1,\n index: 0,\n session\n }, target, customType));\n } else {\n const chunkSize = chunkStep * 1024 / Uint8Array.BYTES_PER_ELEMENT;\n const len = Math.ceil(size / chunkStep);\n let index = 0;\n while (index < len) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf.slice(index * chunkSize, (index + 1) * chunkSize),\n length: len,\n index: index,\n session\n }, target, customType));\n index += 1;\n }\n }\n }\n async userList() {\n const output = new Set();\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false\n });\n let nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n while (nextPage) {\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false,\n page: nextPage\n });\n nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n }\n return output;\n }\n async historyMessage(_begin, _end) {\n return null;\n }\n}", "export const cyrb53 = function (str) {\n let seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n let h1 = 0xdeadbeef ^ seed,\n h2 = 0x41c6ce57 ^ seed;\n for (let i = 0, ch; i < str.length; i++) {\n ch = str.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);\n h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);\n h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);\n h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);\n return 4294967296 * (2097151 & h2) + (h1 >>> 0);\n};", "function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nexport class ChunkedUpdateMessage {\n static fromObject(obj, target, customType) {\n const msg = new ChunkedUpdateMessage();\n msg.target = target;\n msg.customType = customType;\n const encoder = new TextEncoder();\n const sessionBuf = encoder.encode(obj.session);\n\n // header \u6309\u987A\u5E8F\u6307\u793A buf, session, target, customType \u90E8\u5206\u7684 uint8 \u957F\u5EA6\n msg.header = new DataView(new Uint8Array(10).buffer);\n msg.header.setUint32(0, obj.buf.length, false);\n msg.header.setUint32(4, sessionBuf.length, false);\n msg.header.setUint8(8, obj.index);\n msg.header.setUint8(9, obj.length);\n msg.buffer = new Uint8Array(obj.buf.length + sessionBuf.length + msg.header.buffer.byteLength);\n let len = 0;\n msg.buffer.set(new Uint8Array(msg.header.buffer), len);\n len += msg.header.buffer.byteLength;\n msg.buffer.set(obj.buf, len);\n len += obj.buf.length;\n msg.buffer.set(sessionBuf, len);\n return msg;\n }\n static fromBuffer(buf, target, customType) {\n const msg = new ChunkedUpdateMessage();\n msg.header = new DataView(buf.slice(0, 10).buffer);\n msg.buffer = buf.slice(10);\n msg.target = target;\n msg.customType = customType;\n return msg;\n }\n get buf() {\n const len = this.header.getInt32(0);\n return this.buffer.slice(0, len);\n }\n get index() {\n return this.header.getUint8(8);\n }\n get length() {\n return this.header.getUint8(9);\n }\n get session() {\n const start = this.header.getInt32(0);\n const sessionBuf = this.buffer.slice(start, start + this.header.getInt32(4));\n const textDecoder = new TextDecoder();\n return textDecoder.decode(sessionBuf);\n }\n constructor() {\n _defineProperty(this, \"target\", void 0);\n _defineProperty(this, \"customType\", void 0);\n _defineProperty(this, \"buffer\", void 0);\n _defineProperty(this, \"header\", void 0);\n }\n}", "function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nimport { log } from '@netless/forge-room';\nimport EventEmitter from 'eventemitter3';\nimport { v4 as uuidv4 } from 'uuid';\nimport { cyrb53 } from './utils';\nimport { ChunkedUpdateMessage } from './ChunkedUpdateMessage';\nexport class RTMProvider_2_2 extends EventEmitter {\n get calibrationTimestamp() {\n return this.rtmTimestamp + this.deviation;\n }\n constructor(rtmClient) {\n super();\n _defineProperty(this, \"rtmClient\", void 0);\n _defineProperty(this, \"roomId\", void 0);\n _defineProperty(this, \"userId\", void 0);\n _defineProperty(this, \"reconnectTimeout\", null);\n _defineProperty(this, \"chunkedMessages\", new Map());\n _defineProperty(this, \"cachedMessages\", []);\n _defineProperty(this, \"lastCachedMessageReportTime\", 0);\n _defineProperty(this, \"intervalId\", null);\n _defineProperty(this, \"deviation\", 0);\n _defineProperty(this, \"rtmTimestamp\", 0);\n _defineProperty(this, \"animationStartTimestamp\", void 0);\n _defineProperty(this, \"animationId\", void 0);\n _defineProperty(this, \"handleRtmMessage\", evt => {\n try {\n const isRoomChannel = evt.channelName.indexOf('_u_') < 0;\n if (!(evt.message instanceof Uint8Array) || !this.isForgeRoomChannel(evt.channelName)) {\n return;\n }\n if (this.animationId) {\n cancelAnimationFrame(this.animationId);\n this.animationStartTimestamp = undefined;\n this.animationId = undefined;\n this.deviation = 0;\n }\n this.rtmTimestamp = evt.timestamp || Date.now();\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n this.receiveChunkMessage(ChunkedUpdateMessage.fromBuffer(evt.message, '', evt.customType), evt.publisher, isRoomChannel);\n } catch (e) {\n log('rtm handle message error', {\n error: e.toString()\n }, 'error');\n }\n });\n _defineProperty(this, \"calibrateAnimate\", timestamp => {\n if (this.animationStartTimestamp === undefined) {\n this.animationStartTimestamp = timestamp;\n }\n this.deviation = timestamp - this.animationStartTimestamp;\n if (this.animationId) {\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n }\n });\n _defineProperty(this, \"handleStatus\", connectionStatus => {\n log('rtm status update', {\n state: connectionStatus.state,\n reason: connectionStatus.reason,\n rtm: '2.2'\n });\n if (connectionStatus.state === 'RECONNECTING' && this.reconnectTimeout === null) {\n this.emit('connectionStatusChange', 'RECONNECTING');\n this.emit('userLeave', this.userId);\n this.reconnectTimeout = window.setTimeout(() => {\n this.emit('error', 'reconnecting timeout');\n this.emit('connectionStatusChange', 'DISCONNECTED');\n }, 30 * 1000);\n } else if (connectionStatus.state === 'CONNECTED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('connectionStatusChange', 'CONNECTED');\n this.emit('userJoin', this.userId);\n } else if (connectionStatus.state === 'FAILED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('error', `rtm connection failed, ${connectionStatus.reason}`);\n this.emit('connectionStatusChange', 'DISCONNECTED');\n this.emit('userLeave', this.userId);\n } else if (connectionStatus.state === 'CONNECTING') {\n this.emit('connectionStatusChange', 'CONNECTING');\n this.emit('userLeave', this.userId);\n }\n });\n _defineProperty(this, \"handlePresence\", evt => {\n if (evt.channelName === this.roomChannel()) {\n if (evt.eventType === 'REMOTE_JOIN') {\n this.emit('userJoin', evt.publisher);\n } else if (evt.eventType === 'REMOTE_LEAVE') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'REMOTE_TIMEOUT') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'INTERVAL') {\n // evt.interval.join.users\n }\n }\n });\n this.rtmClient = rtmClient;\n }\n roomChannel() {\n return `r_${this.roomId}`;\n }\n userChannel(userId) {\n if (userId.length > 16) {\n userId = `${cyrb53(userId)}`;\n }\n return `${this.roomChannel()}_u_${userId}`;\n }\n async initialize(roomId, userId) {\n window.clearInterval(this.intervalId);\n this.roomId = roomId;\n this.userId = userId;\n this.rtmClient.addEventListener('message', this.handleRtmMessage);\n this.rtmClient.addEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.addEventListener('status', this.handleStatus);\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString(),\n rtm: '2.2'\n }, 'error');\n throw error;\n }\n this.intervalId = setInterval(() => {\n const msg = this.cachedMessages.shift();\n if (msg) {\n const channel = msg.target ? this.userChannel(msg.target) : this.roomChannel();\n this.rtmClient.publish(channel, msg.buffer, {\n customType: msg.customType,\n storeInHistory: true\n }).catch(error => {\n log('rtm publish failed', {\n channel,\n code: error.code,\n rtm: '2.2'\n }, 'warn');\n this.emit('error', `rtm publish fail, ${error}`);\n });\n }\n }, 32);\n }\n\n /**\n * \u91CD\u65B0\u8BA2\u9605\u9891\u9053\n */\n async resubscribe() {\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n }\n }\n async dispose() {\n this.rtmClient.removeEventListener('message', this.handleRtmMessage);\n this.rtmClient.removeEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.removeEventListener('status', this.handleStatus);\n await this.rtmClient.unsubscribe(this.roomChannel());\n await this.rtmClient.unsubscribe(this.userChannel(this.userId));\n window.clearInterval(this.intervalId);\n }\n isForgeRoomChannel(channel) {\n return channel === this.roomChannel() || channel === this.userChannel(this.userId);\n }\n receiveChunkMessage(msg, publisher, isRoomChannel) {\n if (msg.length === 1) {\n this.emit('message', msg.buf, publisher, msg.customType, isRoomChannel);\n return;\n }\n const chunks = this.chunkedMessages.get(msg.session) || [];\n chunks.push(msg);\n if (chunks.length === msg.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n this.emit('message', buffer, publisher, msg.customType, isRoomChannel);\n this.chunkedMessages.delete(msg.session);\n } else {\n this.chunkedMessages.set(msg.session, chunks);\n }\n }\n publish(buf, customType) {\n let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';\n if (this.cachedMessages.length > 150 && Date.now() - this.lastCachedMessageReportTime > 5000) {\n log(`rtm cached message too many: ${this.cachedMessages.length}`, {}, 'warn');\n this.lastCachedMessageReportTime = Date.now();\n }\n const chunkStep = 24;\n const session = uuidv4();\n // \u6D88\u606F\u5305\u4F53\u79EF, \u5355\u4F4D kb\n const size = buf.length * Uint8Array.BYTES_PER_ELEMENT / 1024;\n if (size < chunkStep) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf,\n length: 1,\n index: 0,\n session\n }, target, customType));\n } else {\n const chunkSize = chunkStep * 1024 / Uint8Array.BYTES_PER_ELEMENT;\n const len = Math.ceil(size / chunkStep);\n let index = 0;\n while (index < len) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf.slice(index * chunkSize, (index + 1) * chunkSize),\n length: len,\n index: index,\n session\n }, target, customType));\n index += 1;\n }\n }\n }\n async userList() {\n const output = new Set();\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false\n });\n let nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n while (nextPage) {\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false,\n page: nextPage\n });\n nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n }\n return output;\n }\n async fetchHistoryMessage(begin, end, channel) {\n let start = begin;\n let continueFetch = true;\n const output = [];\n while (continueFetch) {\n const response = await this.rtmClient.history.getMessages(channel, 'MESSAGE', {\n start: start,\n end: end\n });\n if (response.newStart !== 0) {\n start = response.newStart;\n } else {\n continueFetch = false;\n }\n const chunkedMessages = new Map();\n for (const msg of response.messageList) {\n const chunked = ChunkedUpdateMessage.fromBuffer(msg.message, msg.publisher, msg.customType);\n if (chunked.length === 1) {\n output.push({\n buf: chunked.buf,\n publisher: msg.publisher,\n customType: msg.customType,\n isRoomChannel: channel === this.roomChannel()\n });\n } else {\n const chunks = chunkedMessages.get(chunked.session) || [];\n chunks.push(chunked);\n if (chunks.length === chunked.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n output.push({\n buf: buffer,\n publisher: msg.publisher,\n customType: msg.customType,\n isRoomChannel: channel === this.roomChannel()\n });\n chunkedMessages.delete(chunked.session);\n } else {\n chunkedMessages.set(chunked.session, chunks);\n }\n }\n }\n }\n return output;\n }\n async historyMessage(begin, end) {\n try {\n const roomMessages = await this.fetchHistoryMessage(end, begin, this.roomChannel());\n const userMessages = await this.fetchHistoryMessage(end, begin, this.userChannel(this.userId));\n return roomMessages.concat(userMessages);\n } catch (error) {\n this.emit('error', 'rtm historyMessage not support: ' + error);\n console.warn('rtm historyMessage not support: ' + error);\n return null;\n }\n }\n}"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,WAAW;AACpB,OAAO,kBAAkB;AACzB,SAAS,MAAM,cAAc;;;ACLtB,IAAM,SAAS,SAAU,KAAK;AACnC,MAAI,OAAO,UAAU,SAAS,KAAK,UAAU,CAAC,MAAM,SAAY,UAAU,CAAC,IAAI;AAC/E,MAAI,KAAK,aAAa,MACpB,KAAK,aAAa;AACpB,WAAS,IAAI,GAAG,IAAI,IAAI,IAAI,QAAQ,KAAK;AACvC,SAAK,IAAI,WAAW,CAAC;AACrB,SAAK,KAAK,KAAK,KAAK,IAAI,UAAU;AAClC,SAAK,KAAK,KAAK,KAAK,IAAI,UAAU;AAAA,EACpC;AACA,OAAK,KAAK,KAAK,KAAK,OAAO,IAAI,UAAU;AACzC,QAAM,KAAK,KAAK,KAAK,OAAO,IAAI,UAAU;AAC1C,OAAK,KAAK,KAAK,KAAK,OAAO,IAAI,UAAU;AACzC,QAAM,KAAK,KAAK,KAAK,OAAO,IAAI,UAAU;AAC1C,SAAO,cAAc,UAAU,OAAO,OAAO;AAC/C;;;ACdA,SAAS,gBAAgB,GAAG,GAAG,GAAG;AAAE,UAAQ,IAAI,eAAe,CAAC,MAAM,IAAI,OAAO,eAAe,GAAG,GAAG,EAAE,OAAO,GAAG,YAAY,MAAI,cAAc,MAAI,UAAU,KAAG,CAAC,IAAI,EAAE,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AO;AAAA,UACxC,OAAO;AACL,4BAAgB,IAAI,QAAQ,SAAS,MAAM;AAAA,UAC7C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EACA,MAAM,eAAe,OAAO,KAAK;AAC/B,QAAI;AACF,YAAM,eAAe,MAAM,KAAK,oBAAoB,KAAK,OAAO,KAAK,YAAY,CAAC;AAClF,YAAM,eAAe,MAAM,KAAK,oBAAoB,KAAK,OAAO,KAAK,YAAY,KAAK,MAAM,CAAC;AAC7F,aAAO,aAAa,OAAO,YAAY;AAAA,IACzC,SAAS,OAAO;AACd,WAAK,KAAK,SAAS,qCAAqC,KAAK;AAC7D,cAAQ,KAAK,qCAAqC,KAAK;AACvD,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
|
6
|
-
"names": ["_defineProperty", "_toPropertyKey", "_toPrimitive", "result", "log", "EventEmitter", "uuidv4", "_defineProperty", "_toPropertyKey", "_toPrimitive", "EventEmitter", "log", "uuidv4", "result", "output"]
|
|
4
|
+
"sourcesContent": ["function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nimport { log } from '@netless/forge-room';\nimport EventEmitter from 'eventemitter3';\nimport { v4 as uuidv4 } from 'uuid';\nimport { cyrb53 } from './utils';\nimport { ChunkedUpdateMessage } from './ChunkedUpdateMessage';\nexport class RTMProvider_2_1 extends EventEmitter {\n get calibrationTimestamp() {\n return this.rtmTimestamp + this.deviation;\n }\n constructor(rtmClient) {\n super();\n _defineProperty(this, \"rtmClient\", void 0);\n _defineProperty(this, \"roomId\", void 0);\n _defineProperty(this, \"userId\", void 0);\n _defineProperty(this, \"reconnectTimeout\", null);\n _defineProperty(this, \"chunkedMessages\", new Map());\n _defineProperty(this, \"cachedMessages\", []);\n _defineProperty(this, \"intervalId\", null);\n _defineProperty(this, \"deviation\", 0);\n _defineProperty(this, \"rtmTimestamp\", 0);\n _defineProperty(this, \"animationStartTimestamp\", void 0);\n _defineProperty(this, \"animationId\", void 0);\n _defineProperty(this, \"cachedWritable\", new Map());\n _defineProperty(this, \"isInitialized\", false);\n _defineProperty(this, \"handleRtmMessage\", evt => {\n try {\n const isRoomChannel = evt.channelName.indexOf('_u_') < 0;\n if (!(evt.message instanceof Uint8Array) || !this.isForgeRoomChannel(evt.channelName)) {\n return;\n }\n if (this.animationId) {\n cancelAnimationFrame(this.animationId);\n this.animationStartTimestamp = undefined;\n this.animationId = undefined;\n this.deviation = 0;\n }\n this.rtmTimestamp = evt.timestamp || Date.now();\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n // console.log(\"rtm timestamp\", evt.timestamp, \"calibrationTimestamp\", this.calibrationTimestamp);\n this.receiveChunkMessage(ChunkedUpdateMessage.fromBuffer(evt.message, '', evt.customType), evt.publisher, isRoomChannel);\n } catch (error) {\n log('rtm handle message error', {\n error: error.toString()\n }, 'error');\n }\n });\n _defineProperty(this, \"calibrateAnimate\", timestamp => {\n if (this.animationStartTimestamp === undefined) {\n this.animationStartTimestamp = timestamp;\n }\n this.deviation = timestamp - this.animationStartTimestamp;\n if (this.animationId) {\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n }\n });\n _defineProperty(this, \"handleStorageEvent\", storageData => {\n if (storageData.channelName === this.writableChannel()) {\n // \u5904\u7406 writable \u72B6\u6001\u53D8\u66F4\uFF0C\u7EC4\u7EC7\u6240\u6709\u4EBA\u7684 writable \u72B6\u6001\n const writableStates = {};\n const metadata = storageData.data.metadata;\n for (const userId in metadata) {\n const value = metadata[userId].value;\n writableStates[userId] = value === 'true';\n }\n this.emit('writableChanged', writableStates);\n }\n });\n _defineProperty(this, \"handleStatus\", connectionStatus => {\n log('rtm status update', {\n state: connectionStatus.state,\n reason: connectionStatus.reason\n });\n if (connectionStatus.state === 'RECONNECTING' && this.reconnectTimeout === null) {\n this.emit('connectionStatusChange', 'RECONNECTING');\n this.reconnectTimeout = window.setTimeout(() => {\n this.emit('error', 'reconnecting timeout');\n this.emit('connectionStatusChange', 'DISCONNECTED');\n }, 30 * 1000);\n } else if (connectionStatus.state === 'CONNECTED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('connectionStatusChange', 'CONNECTED');\n } else if (connectionStatus.state === 'FAILED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('error', `rtm connection failed, ${connectionStatus.reason}`);\n this.emit('connectionStatusChange', 'DISCONNECTED');\n } else if (connectionStatus.state === 'CONNECTING') {\n this.emit('connectionStatusChange', 'CONNECTING');\n }\n });\n _defineProperty(this, \"handlePresence\", evt => {\n if (evt.channelName === this.roomChannel()) {\n if (evt.eventType === 'REMOTE_JOIN') {\n this.emit('userJoin', evt.publisher);\n } else if (evt.eventType === 'REMOTE_LEAVE') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'REMOTE_TIMEOUT') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'INTERVAL') {\n // evt.interval.join.users\n }\n }\n });\n this.rtmClient = rtmClient;\n }\n roomChannel() {\n return `r_${this.roomId}`;\n }\n userChannel(userId) {\n if (userId.length > 16) {\n userId = `${cyrb53(userId)}`;\n }\n return `${this.roomChannel()}_u_${userId}`;\n }\n writableChannel() {\n return 'userWritable';\n }\n\n /**\n * \u91CD\u65B0\u8BA2\u9605\u9891\u9053\n */\n async resubscribe() {\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n await this.rtmClient.subscribe(this.writableChannel(), {\n withMetadata: true\n });\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n }\n }\n async initialize(roomId, userId) {\n window.clearInterval(this.intervalId);\n this.roomId = roomId;\n this.userId = userId;\n this.rtmClient.addEventListener('message', this.handleRtmMessage);\n this.rtmClient.addEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.addEventListener('status', this.handleStatus);\n this.rtmClient.addEventListener('storage', this.handleStorageEvent);\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n await this.rtmClient.subscribe(this.writableChannel(), {\n withMetadata: true\n });\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n throw error;\n }\n this.isInitialized = true;\n if (this.cachedWritable.size > 0) {\n const writableData = Array.from(this.cachedWritable.entries()).map(_ref => {\n let [userId, writable] = _ref;\n return {\n key: userId,\n value: writable ? 'true' : 'false'\n };\n });\n await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), 'MESSAGE', writableData);\n this.cachedWritable.clear();\n }\n this.intervalId = setInterval(() => {\n const msg = this.cachedMessages.shift();\n if (msg) {\n const channel = msg.target ? this.userChannel(msg.target) : this.roomChannel();\n this.rtmClient.publish(channel, msg.buffer, {\n customType: msg.customType\n }).catch(error => {\n log('rtm publish failed', {\n channel,\n code: error.code\n }, 'warn');\n this.emit('error', `rtm publish fail, ${error}`);\n });\n }\n }, 32);\n }\n async dispose() {\n this.rtmClient.removeEventListener('message', this.handleRtmMessage);\n this.rtmClient.removeEventListener('presence', this.handlePresence);\n this.rtmClient.removeEventListener('storage', this.handleStorageEvent);\n // @ts-ignore\n this.rtmClient.removeEventListener('status', this.handleStatus);\n await this.rtmClient.unsubscribe(this.roomChannel());\n await this.rtmClient.unsubscribe(this.userChannel(this.userId));\n await this.rtmClient.unsubscribe(this.writableChannel());\n window.clearInterval(this.intervalId);\n }\n isForgeRoomChannel(channel) {\n return channel === this.roomChannel() || channel === this.userChannel(this.userId);\n }\n receiveChunkMessage(msg, publisher, isRoomChannel) {\n if (msg.length === 1) {\n this.emit('message', msg.buf, publisher, msg.customType, isRoomChannel);\n return;\n }\n const chunks = this.chunkedMessages.get(msg.session) || [];\n chunks.push(msg);\n if (chunks.length === msg.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n this.emit('message', buffer, publisher, msg.customType, isRoomChannel);\n this.chunkedMessages.delete(msg.session);\n } else {\n this.chunkedMessages.set(msg.session, chunks);\n }\n }\n publish(buf, customType) {\n let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';\n const chunkStep = 24;\n const session = uuidv4();\n // \u6D88\u606F\u5305\u4F53\u79EF, \u5355\u4F4D kb\n const size = buf.length * Uint8Array.BYTES_PER_ELEMENT / 1024;\n if (size < chunkStep) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf,\n length: 1,\n index: 0,\n session\n }, target, customType));\n } else {\n const chunkSize = chunkStep * 1024 / Uint8Array.BYTES_PER_ELEMENT;\n const len = Math.ceil(size / chunkStep);\n let index = 0;\n while (index < len) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf.slice(index * chunkSize, (index + 1) * chunkSize),\n length: len,\n index: index,\n session\n }, target, customType));\n index += 1;\n }\n }\n }\n async userList() {\n const output = new Set();\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false\n });\n let nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n while (nextPage) {\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false,\n page: nextPage\n });\n nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n }\n return output;\n }\n async historyMessage(_begin, _end) {\n return null;\n }\n async setUserWritable(writable, userId) {\n // \u7F13\u5B58\u7684\u4F5C\u7528\u662F\u52A0\u5165\u9891\u9053\u4E4B\u540E\u624D\u80FD\u8C03\u7528 setChannelMetadata\uFF0C\u6240\u4EE5\u7F13\u5B58\u5E94\u8BE5\u5728\u52A0\u5165\u9891\u9053\u6210\u529F\u540E\u5220\u9664\n const targetUserId = userId || this.userId;\n if (!this.isInitialized) {\n this.cachedWritable.set(targetUserId, writable);\n return;\n }\n await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), 'MESSAGE', [{\n key: targetUserId,\n value: writable ? 'true' : 'false'\n }]);\n }\n async getUserWritable(userId) {\n const targetUserId = userId || this.userId;\n try {\n const channelMeta = await this.rtmClient.storage.getChannelMetadata(this.writableChannel(), 'MESSAGE');\n const value = channelMeta.metadata[targetUserId]?.value;\n return value === 'true';\n } catch (error) {\n log('getUserWritable failed', {\n error: error.toString(),\n userId: targetUserId\n }, 'warn');\n return true;\n }\n }\n}", "export const cyrb53 = function (str) {\n let seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n let h1 = 0xdeadbeef ^ seed,\n h2 = 0x41c6ce57 ^ seed;\n for (let i = 0, ch; i < str.length; i++) {\n ch = str.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);\n h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);\n h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);\n h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);\n return 4294967296 * (2097151 & h2) + (h1 >>> 0);\n};", "function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nexport class ChunkedUpdateMessage {\n static fromObject(obj, target, customType) {\n const msg = new ChunkedUpdateMessage();\n msg.target = target;\n msg.customType = customType;\n const encoder = new TextEncoder();\n const sessionBuf = encoder.encode(obj.session);\n\n // header \u6309\u987A\u5E8F\u6307\u793A buf, session, target, customType \u90E8\u5206\u7684 uint8 \u957F\u5EA6\n msg.header = new DataView(new Uint8Array(10).buffer);\n msg.header.setUint32(0, obj.buf.length, false);\n msg.header.setUint32(4, sessionBuf.length, false);\n msg.header.setUint8(8, obj.index);\n msg.header.setUint8(9, obj.length);\n msg.buffer = new Uint8Array(obj.buf.length + sessionBuf.length + msg.header.buffer.byteLength);\n let len = 0;\n msg.buffer.set(new Uint8Array(msg.header.buffer), len);\n len += msg.header.buffer.byteLength;\n msg.buffer.set(obj.buf, len);\n len += obj.buf.length;\n msg.buffer.set(sessionBuf, len);\n return msg;\n }\n static fromBuffer(buf, target, customType) {\n const msg = new ChunkedUpdateMessage();\n msg.header = new DataView(buf.slice(0, 10).buffer);\n msg.buffer = buf.slice(10);\n msg.target = target;\n msg.customType = customType;\n return msg;\n }\n get buf() {\n const len = this.header.getInt32(0);\n return this.buffer.slice(0, len);\n }\n get index() {\n return this.header.getUint8(8);\n }\n get length() {\n return this.header.getUint8(9);\n }\n get session() {\n const start = this.header.getInt32(0);\n const sessionBuf = this.buffer.slice(start, start + this.header.getInt32(4));\n const textDecoder = new TextDecoder();\n return textDecoder.decode(sessionBuf);\n }\n constructor() {\n _defineProperty(this, \"target\", void 0);\n _defineProperty(this, \"customType\", void 0);\n _defineProperty(this, \"buffer\", void 0);\n _defineProperty(this, \"header\", void 0);\n }\n}", "function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nimport { log } from '@netless/forge-room';\nimport EventEmitter from 'eventemitter3';\nimport { v4 as uuidv4 } from 'uuid';\nimport { cyrb53 } from './utils';\nimport { ChunkedUpdateMessage } from './ChunkedUpdateMessage';\nexport class RTMProvider_2_2 extends EventEmitter {\n get calibrationTimestamp() {\n return this.rtmTimestamp + this.deviation;\n }\n constructor(rtmClient) {\n super();\n _defineProperty(this, \"rtmClient\", void 0);\n _defineProperty(this, \"roomId\", void 0);\n _defineProperty(this, \"userId\", void 0);\n _defineProperty(this, \"reconnectTimeout\", null);\n _defineProperty(this, \"chunkedMessages\", new Map());\n _defineProperty(this, \"cachedMessages\", []);\n _defineProperty(this, \"lastCachedMessageReportTime\", 0);\n _defineProperty(this, \"intervalId\", null);\n _defineProperty(this, \"deviation\", 0);\n _defineProperty(this, \"rtmTimestamp\", 0);\n _defineProperty(this, \"animationStartTimestamp\", void 0);\n _defineProperty(this, \"animationId\", void 0);\n _defineProperty(this, \"cachedWritable\", new Map());\n _defineProperty(this, \"isInitialized\", false);\n _defineProperty(this, \"handleRtmMessage\", evt => {\n try {\n const isRoomChannel = evt.channelName.indexOf('_u_') < 0;\n if (!(evt.message instanceof Uint8Array) || !this.isForgeRoomChannel(evt.channelName)) {\n return;\n }\n if (this.animationId) {\n cancelAnimationFrame(this.animationId);\n this.animationStartTimestamp = undefined;\n this.animationId = undefined;\n this.deviation = 0;\n }\n this.rtmTimestamp = evt.timestamp || Date.now();\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n this.receiveChunkMessage(ChunkedUpdateMessage.fromBuffer(evt.message, '', evt.customType), evt.publisher, isRoomChannel);\n } catch (e) {\n log('rtm handle message error', {\n error: e.toString()\n }, 'error');\n }\n });\n _defineProperty(this, \"calibrateAnimate\", timestamp => {\n if (this.animationStartTimestamp === undefined) {\n this.animationStartTimestamp = timestamp;\n }\n this.deviation = timestamp - this.animationStartTimestamp;\n if (this.animationId) {\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n }\n });\n _defineProperty(this, \"handleStorageEvent\", storageData => {\n if (storageData.channelName === this.writableChannel()) {\n // \u5904\u7406 writable \u72B6\u6001\u53D8\u66F4\uFF0C\u7EC4\u7EC7\u6240\u6709\u4EBA\u7684 writable \u72B6\u6001\n const writableStates = {};\n const metadata = storageData.data.metadata;\n for (const userId in metadata) {\n const value = metadata[userId].value;\n writableStates[userId] = value === 'true';\n }\n this.emit('writableChanged', writableStates);\n }\n });\n _defineProperty(this, \"handleStatus\", connectionStatus => {\n log('rtm status update', {\n state: connectionStatus.state,\n reason: connectionStatus.reason,\n rtm: '2.2'\n });\n if (connectionStatus.state === 'RECONNECTING' && this.reconnectTimeout === null) {\n this.emit('connectionStatusChange', 'RECONNECTING');\n this.emit('userLeave', this.userId);\n this.reconnectTimeout = window.setTimeout(() => {\n this.emit('error', 'reconnecting timeout');\n this.emit('connectionStatusChange', 'DISCONNECTED');\n }, 30 * 1000);\n } else if (connectionStatus.state === 'CONNECTED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('connectionStatusChange', 'CONNECTED');\n this.emit('userJoin', this.userId);\n } else if (connectionStatus.state === 'FAILED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('error', `rtm connection failed, ${connectionStatus.reason}`);\n this.emit('connectionStatusChange', 'DISCONNECTED');\n this.emit('userLeave', this.userId);\n } else if (connectionStatus.state === 'CONNECTING') {\n this.emit('connectionStatusChange', 'CONNECTING');\n this.emit('userLeave', this.userId);\n }\n });\n _defineProperty(this, \"handlePresence\", evt => {\n if (evt.channelName === this.roomChannel()) {\n if (evt.eventType === 'REMOTE_JOIN') {\n this.emit('userJoin', evt.publisher);\n } else if (evt.eventType === 'REMOTE_LEAVE') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'REMOTE_TIMEOUT') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'INTERVAL') {\n // evt.interval.join.users\n }\n }\n });\n this.rtmClient = rtmClient;\n }\n roomChannel() {\n return `r_${this.roomId}`;\n }\n writableChannel() {\n return `${this.roomChannel()}_uw`;\n }\n userChannel(userId) {\n if (userId.length > 16) {\n userId = `${cyrb53(userId)}`;\n }\n return `${this.roomChannel()}_u_${userId}`;\n }\n async initialize(roomId, userId) {\n window.clearInterval(this.intervalId);\n this.roomId = roomId;\n this.userId = userId;\n this.rtmClient.addEventListener('message', this.handleRtmMessage);\n this.rtmClient.addEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.addEventListener('status', this.handleStatus);\n this.rtmClient.addEventListener('storage', this.handleStorageEvent);\n try {\n await this.rtmClient.subscribe(this.roomChannel(), {\n withPresence: true\n });\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n await this.rtmClient.subscribe(this.writableChannel(), {\n withMetadata: true\n });\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString(),\n rtm: '2.2'\n }, 'error');\n throw error;\n }\n this.intervalId = setInterval(() => {\n const msg = this.cachedMessages.shift();\n if (msg) {\n const channel = msg.target ? this.userChannel(msg.target) : this.roomChannel();\n this.rtmClient.publish(channel, msg.buffer, {\n customType: msg.customType,\n storeInHistory: true\n }).catch(error => {\n log('rtm publish failed', {\n channel,\n code: error.code,\n rtm: '2.2'\n }, 'warn');\n this.emit('error', `rtm publish fail, ${error}`);\n });\n }\n }, 32);\n this.isInitialized = true;\n if (this.cachedWritable.size > 0) {\n const writableData = Array.from(this.cachedWritable.entries()).map(_ref => {\n let [userId, writable] = _ref;\n return {\n key: userId,\n value: writable ? 'true' : 'false'\n };\n });\n await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), 'MESSAGE', writableData);\n this.cachedWritable.clear();\n }\n }\n\n /**\n * \u91CD\u65B0\u8BA2\u9605\u9891\u9053\n */\n async resubscribe() {\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n await this.rtmClient.subscribe(this.writableChannel(), {\n withMetadata: true\n });\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n }\n }\n async dispose() {\n this.rtmClient.removeEventListener('message', this.handleRtmMessage);\n this.rtmClient.removeEventListener('presence', this.handlePresence);\n this.rtmClient.removeEventListener('storage', this.handleStorageEvent);\n // @ts-ignore\n this.rtmClient.removeEventListener('status', this.handleStatus);\n await this.rtmClient.unsubscribe(this.roomChannel());\n await this.rtmClient.unsubscribe(this.userChannel(this.userId));\n await this.rtmClient.unsubscribe(this.writableChannel());\n window.clearInterval(this.intervalId);\n }\n isForgeRoomChannel(channel) {\n return channel === this.roomChannel() || channel === this.userChannel(this.userId);\n }\n receiveChunkMessage(msg, publisher, isRoomChannel) {\n if (msg.length === 1) {\n this.emit('message', msg.buf, publisher, msg.customType, isRoomChannel);\n return;\n }\n const chunks = this.chunkedMessages.get(msg.session) || [];\n chunks.push(msg);\n if (chunks.length === msg.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n this.emit('message', buffer, publisher, msg.customType, isRoomChannel);\n this.chunkedMessages.delete(msg.session);\n } else {\n this.chunkedMessages.set(msg.session, chunks);\n }\n }\n publish(buf, customType) {\n let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';\n if (this.cachedMessages.length > 150 && Date.now() - this.lastCachedMessageReportTime > 5000) {\n log(`rtm cached message too many: ${this.cachedMessages.length}`, {}, 'warn');\n this.lastCachedMessageReportTime = Date.now();\n }\n const chunkStep = 24;\n const session = uuidv4();\n // \u6D88\u606F\u5305\u4F53\u79EF, \u5355\u4F4D kb\n const size = buf.length * Uint8Array.BYTES_PER_ELEMENT / 1024;\n if (size < chunkStep) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf,\n length: 1,\n index: 0,\n session\n }, target, customType));\n } else {\n const chunkSize = chunkStep * 1024 / Uint8Array.BYTES_PER_ELEMENT;\n const len = Math.ceil(size / chunkStep);\n let index = 0;\n while (index < len) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf.slice(index * chunkSize, (index + 1) * chunkSize),\n length: len,\n index: index,\n session\n }, target, customType));\n index += 1;\n }\n }\n }\n async userList() {\n const output = new Set();\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false\n });\n let nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n while (nextPage) {\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false,\n page: nextPage\n });\n nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n }\n return output;\n }\n async fetchHistoryMessage(begin, end, channel) {\n let start = begin;\n let continueFetch = true;\n const output = [];\n while (continueFetch) {\n const response = await this.rtmClient.history.getMessages(channel, 'MESSAGE', {\n start: start,\n end: end\n });\n if (response.newStart !== 0) {\n start = response.newStart;\n } else {\n continueFetch = false;\n }\n const chunkedMessages = new Map();\n for (const msg of response.messageList) {\n const chunked = ChunkedUpdateMessage.fromBuffer(msg.message, msg.publisher, msg.customType);\n if (chunked.length === 1) {\n output.push({\n buf: chunked.buf,\n publisher: msg.publisher,\n customType: msg.customType,\n isRoomChannel: channel === this.roomChannel()\n });\n } else {\n const chunks = chunkedMessages.get(chunked.session) || [];\n chunks.push(chunked);\n if (chunks.length === chunked.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n output.push({\n buf: buffer,\n publisher: msg.publisher,\n customType: msg.customType,\n isRoomChannel: channel === this.roomChannel()\n });\n chunkedMessages.delete(chunked.session);\n } else {\n chunkedMessages.set(chunked.session, chunks);\n }\n }\n }\n }\n return output;\n }\n async historyMessage(begin, end) {\n try {\n const roomMessages = await this.fetchHistoryMessage(end, begin, this.roomChannel());\n const userMessages = await this.fetchHistoryMessage(end, begin, this.userChannel(this.userId));\n return roomMessages.concat(userMessages);\n } catch (error) {\n this.emit('error', 'rtm historyMessage not support: ' + error);\n console.warn('rtm historyMessage not support: ' + error);\n return null;\n }\n }\n async setUserWritable(writable, userId) {\n // \u7F13\u5B58\u7684\u4F5C\u7528\u662F\u52A0\u5165\u9891\u9053\u4E4B\u540E\u624D\u80FD\u8C03\u7528 setChannelMetadata\uFF0C\u6240\u4EE5\u7F13\u5B58\u5E94\u8BE5\u5728\u52A0\u5165\u9891\u9053\u6210\u529F\u540E\u5220\u9664\n const targetUserId = userId || this.userId;\n if (!this.isInitialized) {\n this.cachedWritable.set(targetUserId, writable);\n return;\n }\n await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), 'MESSAGE', [{\n key: targetUserId,\n value: writable ? 'true' : 'false'\n }]);\n }\n async getUserWritable(userId) {\n const targetUserId = userId || this.userId;\n try {\n const channelMeta = await this.rtmClient.storage.getChannelMetadata(this.writableChannel(), 'MESSAGE');\n const value = channelMeta.metadata[targetUserId]?.value;\n return value === 'true';\n } catch (error) {\n log('getUserWritable failed', {\n error: error.toString(),\n userId: targetUserId,\n rtm: '2.2'\n },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AAI,0BAA0B;AAAA,QAC5B,OAAO,MAAM,SAAS;AAAA,QACtB,QAAQ;AAAA,QACR,KAAK;AAAA,MACP,GAAG,MAAM;AACT,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["_defineProperty", "_toPropertyKey", "_toPrimitive", "userId", "result", "log", "EventEmitter", "uuidv4", "_defineProperty", "_toPropertyKey", "_toPrimitive", "EventEmitter", "log", "userId", "uuidv4", "result", "output"]
|
|
7
7
|
}
|
package/dist/rtm-provider.js
CHANGED
|
@@ -162,6 +162,8 @@ var RTMProvider_2_1 = class extends import_eventemitter3.default {
|
|
|
162
162
|
_defineProperty2(this, "rtmTimestamp", 0);
|
|
163
163
|
_defineProperty2(this, "animationStartTimestamp", void 0);
|
|
164
164
|
_defineProperty2(this, "animationId", void 0);
|
|
165
|
+
_defineProperty2(this, "cachedWritable", /* @__PURE__ */ new Map());
|
|
166
|
+
_defineProperty2(this, "isInitialized", false);
|
|
165
167
|
_defineProperty2(this, "handleRtmMessage", (evt) => {
|
|
166
168
|
try {
|
|
167
169
|
const isRoomChannel = evt.channelName.indexOf("_u_") < 0;
|
|
@@ -192,6 +194,17 @@ var RTMProvider_2_1 = class extends import_eventemitter3.default {
|
|
|
192
194
|
this.animationId = requestAnimationFrame(this.calibrateAnimate);
|
|
193
195
|
}
|
|
194
196
|
});
|
|
197
|
+
_defineProperty2(this, "handleStorageEvent", (storageData) => {
|
|
198
|
+
if (storageData.channelName === this.writableChannel()) {
|
|
199
|
+
const writableStates = {};
|
|
200
|
+
const metadata = storageData.data.metadata;
|
|
201
|
+
for (const userId in metadata) {
|
|
202
|
+
const value = metadata[userId].value;
|
|
203
|
+
writableStates[userId] = value === "true";
|
|
204
|
+
}
|
|
205
|
+
this.emit("writableChanged", writableStates);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
195
208
|
_defineProperty2(this, "handleStatus", (connectionStatus) => {
|
|
196
209
|
(0, import_forge_room.log)("rtm status update", {
|
|
197
210
|
state: connectionStatus.state,
|
|
@@ -237,6 +250,9 @@ var RTMProvider_2_1 = class extends import_eventemitter3.default {
|
|
|
237
250
|
}
|
|
238
251
|
return `${this.roomChannel()}_u_${userId}`;
|
|
239
252
|
}
|
|
253
|
+
writableChannel() {
|
|
254
|
+
return "userWritable";
|
|
255
|
+
}
|
|
240
256
|
/**
|
|
241
257
|
* 重新订阅频道
|
|
242
258
|
*/
|
|
@@ -244,6 +260,9 @@ var RTMProvider_2_1 = class extends import_eventemitter3.default {
|
|
|
244
260
|
try {
|
|
245
261
|
await this.rtmClient.subscribe(this.roomChannel());
|
|
246
262
|
await this.rtmClient.subscribe(this.userChannel(this.userId));
|
|
263
|
+
await this.rtmClient.subscribe(this.writableChannel(), {
|
|
264
|
+
withMetadata: true
|
|
265
|
+
});
|
|
247
266
|
} catch (error) {
|
|
248
267
|
this.emit("error", `rtm subscribe fail, ${error}`);
|
|
249
268
|
(0, import_forge_room.log)("rtm subscribe fail", {
|
|
@@ -258,9 +277,13 @@ var RTMProvider_2_1 = class extends import_eventemitter3.default {
|
|
|
258
277
|
this.rtmClient.addEventListener("message", this.handleRtmMessage);
|
|
259
278
|
this.rtmClient.addEventListener("presence", this.handlePresence);
|
|
260
279
|
this.rtmClient.addEventListener("status", this.handleStatus);
|
|
280
|
+
this.rtmClient.addEventListener("storage", this.handleStorageEvent);
|
|
261
281
|
try {
|
|
262
282
|
await this.rtmClient.subscribe(this.roomChannel());
|
|
263
283
|
await this.rtmClient.subscribe(this.userChannel(this.userId));
|
|
284
|
+
await this.rtmClient.subscribe(this.writableChannel(), {
|
|
285
|
+
withMetadata: true
|
|
286
|
+
});
|
|
264
287
|
} catch (error) {
|
|
265
288
|
this.emit("error", `rtm subscribe fail, ${error}`);
|
|
266
289
|
(0, import_forge_room.log)("rtm subscribe fail", {
|
|
@@ -268,6 +291,18 @@ var RTMProvider_2_1 = class extends import_eventemitter3.default {
|
|
|
268
291
|
}, "error");
|
|
269
292
|
throw error;
|
|
270
293
|
}
|
|
294
|
+
this.isInitialized = true;
|
|
295
|
+
if (this.cachedWritable.size > 0) {
|
|
296
|
+
const writableData = Array.from(this.cachedWritable.entries()).map((_ref) => {
|
|
297
|
+
let [userId2, writable] = _ref;
|
|
298
|
+
return {
|
|
299
|
+
key: userId2,
|
|
300
|
+
value: writable ? "true" : "false"
|
|
301
|
+
};
|
|
302
|
+
});
|
|
303
|
+
await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), "MESSAGE", writableData);
|
|
304
|
+
this.cachedWritable.clear();
|
|
305
|
+
}
|
|
271
306
|
this.intervalId = setInterval(() => {
|
|
272
307
|
const msg = this.cachedMessages.shift();
|
|
273
308
|
if (msg) {
|
|
@@ -287,9 +322,11 @@ var RTMProvider_2_1 = class extends import_eventemitter3.default {
|
|
|
287
322
|
async dispose() {
|
|
288
323
|
this.rtmClient.removeEventListener("message", this.handleRtmMessage);
|
|
289
324
|
this.rtmClient.removeEventListener("presence", this.handlePresence);
|
|
325
|
+
this.rtmClient.removeEventListener("storage", this.handleStorageEvent);
|
|
290
326
|
this.rtmClient.removeEventListener("status", this.handleStatus);
|
|
291
327
|
await this.rtmClient.unsubscribe(this.roomChannel());
|
|
292
328
|
await this.rtmClient.unsubscribe(this.userChannel(this.userId));
|
|
329
|
+
await this.rtmClient.unsubscribe(this.writableChannel());
|
|
293
330
|
window.clearInterval(this.intervalId);
|
|
294
331
|
}
|
|
295
332
|
isForgeRoomChannel(channel) {
|
|
@@ -373,6 +410,31 @@ var RTMProvider_2_1 = class extends import_eventemitter3.default {
|
|
|
373
410
|
async historyMessage(_begin, _end) {
|
|
374
411
|
return null;
|
|
375
412
|
}
|
|
413
|
+
async setUserWritable(writable, userId) {
|
|
414
|
+
const targetUserId = userId || this.userId;
|
|
415
|
+
if (!this.isInitialized) {
|
|
416
|
+
this.cachedWritable.set(targetUserId, writable);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), "MESSAGE", [{
|
|
420
|
+
key: targetUserId,
|
|
421
|
+
value: writable ? "true" : "false"
|
|
422
|
+
}]);
|
|
423
|
+
}
|
|
424
|
+
async getUserWritable(userId) {
|
|
425
|
+
const targetUserId = userId || this.userId;
|
|
426
|
+
try {
|
|
427
|
+
const channelMeta = await this.rtmClient.storage.getChannelMetadata(this.writableChannel(), "MESSAGE");
|
|
428
|
+
const value = channelMeta.metadata[targetUserId]?.value;
|
|
429
|
+
return value === "true";
|
|
430
|
+
} catch (error) {
|
|
431
|
+
(0, import_forge_room.log)("getUserWritable failed", {
|
|
432
|
+
error: error.toString(),
|
|
433
|
+
userId: targetUserId
|
|
434
|
+
}, "warn");
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
376
438
|
};
|
|
377
439
|
|
|
378
440
|
// src/RTM_2_2.ts
|
|
@@ -414,6 +476,8 @@ var RTMProvider_2_2 = class extends import_eventemitter32.default {
|
|
|
414
476
|
_defineProperty3(this, "rtmTimestamp", 0);
|
|
415
477
|
_defineProperty3(this, "animationStartTimestamp", void 0);
|
|
416
478
|
_defineProperty3(this, "animationId", void 0);
|
|
479
|
+
_defineProperty3(this, "cachedWritable", /* @__PURE__ */ new Map());
|
|
480
|
+
_defineProperty3(this, "isInitialized", false);
|
|
417
481
|
_defineProperty3(this, "handleRtmMessage", (evt) => {
|
|
418
482
|
try {
|
|
419
483
|
const isRoomChannel = evt.channelName.indexOf("_u_") < 0;
|
|
@@ -444,6 +508,17 @@ var RTMProvider_2_2 = class extends import_eventemitter32.default {
|
|
|
444
508
|
this.animationId = requestAnimationFrame(this.calibrateAnimate);
|
|
445
509
|
}
|
|
446
510
|
});
|
|
511
|
+
_defineProperty3(this, "handleStorageEvent", (storageData) => {
|
|
512
|
+
if (storageData.channelName === this.writableChannel()) {
|
|
513
|
+
const writableStates = {};
|
|
514
|
+
const metadata = storageData.data.metadata;
|
|
515
|
+
for (const userId in metadata) {
|
|
516
|
+
const value = metadata[userId].value;
|
|
517
|
+
writableStates[userId] = value === "true";
|
|
518
|
+
}
|
|
519
|
+
this.emit("writableChanged", writableStates);
|
|
520
|
+
}
|
|
521
|
+
});
|
|
447
522
|
_defineProperty3(this, "handleStatus", (connectionStatus) => {
|
|
448
523
|
(0, import_forge_room2.log)("rtm status update", {
|
|
449
524
|
state: connectionStatus.state,
|
|
@@ -488,6 +563,9 @@ var RTMProvider_2_2 = class extends import_eventemitter32.default {
|
|
|
488
563
|
roomChannel() {
|
|
489
564
|
return `r_${this.roomId}`;
|
|
490
565
|
}
|
|
566
|
+
writableChannel() {
|
|
567
|
+
return `${this.roomChannel()}_uw`;
|
|
568
|
+
}
|
|
491
569
|
userChannel(userId) {
|
|
492
570
|
if (userId.length > 16) {
|
|
493
571
|
userId = `${cyrb53(userId)}`;
|
|
@@ -501,9 +579,15 @@ var RTMProvider_2_2 = class extends import_eventemitter32.default {
|
|
|
501
579
|
this.rtmClient.addEventListener("message", this.handleRtmMessage);
|
|
502
580
|
this.rtmClient.addEventListener("presence", this.handlePresence);
|
|
503
581
|
this.rtmClient.addEventListener("status", this.handleStatus);
|
|
582
|
+
this.rtmClient.addEventListener("storage", this.handleStorageEvent);
|
|
504
583
|
try {
|
|
505
|
-
await this.rtmClient.subscribe(this.roomChannel()
|
|
584
|
+
await this.rtmClient.subscribe(this.roomChannel(), {
|
|
585
|
+
withPresence: true
|
|
586
|
+
});
|
|
506
587
|
await this.rtmClient.subscribe(this.userChannel(this.userId));
|
|
588
|
+
await this.rtmClient.subscribe(this.writableChannel(), {
|
|
589
|
+
withMetadata: true
|
|
590
|
+
});
|
|
507
591
|
} catch (error) {
|
|
508
592
|
this.emit("error", `rtm subscribe fail, ${error}`);
|
|
509
593
|
(0, import_forge_room2.log)("rtm subscribe fail", {
|
|
@@ -529,6 +613,18 @@ var RTMProvider_2_2 = class extends import_eventemitter32.default {
|
|
|
529
613
|
});
|
|
530
614
|
}
|
|
531
615
|
}, 32);
|
|
616
|
+
this.isInitialized = true;
|
|
617
|
+
if (this.cachedWritable.size > 0) {
|
|
618
|
+
const writableData = Array.from(this.cachedWritable.entries()).map((_ref) => {
|
|
619
|
+
let [userId2, writable] = _ref;
|
|
620
|
+
return {
|
|
621
|
+
key: userId2,
|
|
622
|
+
value: writable ? "true" : "false"
|
|
623
|
+
};
|
|
624
|
+
});
|
|
625
|
+
await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), "MESSAGE", writableData);
|
|
626
|
+
this.cachedWritable.clear();
|
|
627
|
+
}
|
|
532
628
|
}
|
|
533
629
|
/**
|
|
534
630
|
* 重新订阅频道
|
|
@@ -537,6 +633,9 @@ var RTMProvider_2_2 = class extends import_eventemitter32.default {
|
|
|
537
633
|
try {
|
|
538
634
|
await this.rtmClient.subscribe(this.roomChannel());
|
|
539
635
|
await this.rtmClient.subscribe(this.userChannel(this.userId));
|
|
636
|
+
await this.rtmClient.subscribe(this.writableChannel(), {
|
|
637
|
+
withMetadata: true
|
|
638
|
+
});
|
|
540
639
|
} catch (error) {
|
|
541
640
|
this.emit("error", `rtm subscribe fail, ${error}`);
|
|
542
641
|
(0, import_forge_room2.log)("rtm subscribe fail", {
|
|
@@ -547,9 +646,11 @@ var RTMProvider_2_2 = class extends import_eventemitter32.default {
|
|
|
547
646
|
async dispose() {
|
|
548
647
|
this.rtmClient.removeEventListener("message", this.handleRtmMessage);
|
|
549
648
|
this.rtmClient.removeEventListener("presence", this.handlePresence);
|
|
649
|
+
this.rtmClient.removeEventListener("storage", this.handleStorageEvent);
|
|
550
650
|
this.rtmClient.removeEventListener("status", this.handleStatus);
|
|
551
651
|
await this.rtmClient.unsubscribe(this.roomChannel());
|
|
552
652
|
await this.rtmClient.unsubscribe(this.userChannel(this.userId));
|
|
653
|
+
await this.rtmClient.unsubscribe(this.writableChannel());
|
|
553
654
|
window.clearInterval(this.intervalId);
|
|
554
655
|
}
|
|
555
656
|
isForgeRoomChannel(channel) {
|
|
@@ -695,5 +796,31 @@ var RTMProvider_2_2 = class extends import_eventemitter32.default {
|
|
|
695
796
|
return null;
|
|
696
797
|
}
|
|
697
798
|
}
|
|
799
|
+
async setUserWritable(writable, userId) {
|
|
800
|
+
const targetUserId = userId || this.userId;
|
|
801
|
+
if (!this.isInitialized) {
|
|
802
|
+
this.cachedWritable.set(targetUserId, writable);
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), "MESSAGE", [{
|
|
806
|
+
key: targetUserId,
|
|
807
|
+
value: writable ? "true" : "false"
|
|
808
|
+
}]);
|
|
809
|
+
}
|
|
810
|
+
async getUserWritable(userId) {
|
|
811
|
+
const targetUserId = userId || this.userId;
|
|
812
|
+
try {
|
|
813
|
+
const channelMeta = await this.rtmClient.storage.getChannelMetadata(this.writableChannel(), "MESSAGE");
|
|
814
|
+
const value = channelMeta.metadata[targetUserId]?.value;
|
|
815
|
+
return value === "true";
|
|
816
|
+
} catch (error) {
|
|
817
|
+
(0, import_forge_room2.log)("getUserWritable failed", {
|
|
818
|
+
error: error.toString(),
|
|
819
|
+
userId: targetUserId,
|
|
820
|
+
rtm: "2.2"
|
|
821
|
+
}, "warn");
|
|
822
|
+
return true;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
698
825
|
};
|
|
699
826
|
//# sourceMappingURL=rtm-provider.js.map
|
package/dist/rtm-provider.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/RTM_2_1.ts", "../src/utils.ts", "../src/ChunkedUpdateMessage.ts", "../src/RTM_2_2.ts"],
|
|
4
|
-
"sourcesContent": ["export { RTMProvider_2_1 } from './RTM_2_1';\nexport { RTMProvider_2_2 } from './RTM_2_2';", "function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nimport { log } from '@netless/forge-room';\nimport EventEmitter from 'eventemitter3';\nimport { v4 as uuidv4 } from 'uuid';\nimport { cyrb53 } from './utils';\nimport { ChunkedUpdateMessage } from './ChunkedUpdateMessage';\nexport class RTMProvider_2_1 extends EventEmitter {\n get calibrationTimestamp() {\n return this.rtmTimestamp + this.deviation;\n }\n constructor(rtmClient) {\n super();\n _defineProperty(this, \"rtmClient\", void 0);\n _defineProperty(this, \"roomId\", void 0);\n _defineProperty(this, \"userId\", void 0);\n _defineProperty(this, \"reconnectTimeout\", null);\n _defineProperty(this, \"chunkedMessages\", new Map());\n _defineProperty(this, \"cachedMessages\", []);\n _defineProperty(this, \"intervalId\", null);\n _defineProperty(this, \"deviation\", 0);\n _defineProperty(this, \"rtmTimestamp\", 0);\n _defineProperty(this, \"animationStartTimestamp\", void 0);\n _defineProperty(this, \"animationId\", void 0);\n _defineProperty(this, \"handleRtmMessage\", evt => {\n try {\n const isRoomChannel = evt.channelName.indexOf('_u_') < 0;\n if (!(evt.message instanceof Uint8Array) || !this.isForgeRoomChannel(evt.channelName)) {\n return;\n }\n if (this.animationId) {\n cancelAnimationFrame(this.animationId);\n this.animationStartTimestamp = undefined;\n this.animationId = undefined;\n this.deviation = 0;\n }\n this.rtmTimestamp = evt.timestamp || Date.now();\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n // console.log(\"rtm timestamp\", evt.timestamp, \"calibrationTimestamp\", this.calibrationTimestamp);\n this.receiveChunkMessage(ChunkedUpdateMessage.fromBuffer(evt.message, '', evt.customType), evt.publisher, isRoomChannel);\n } catch (error) {\n log('rtm handle message error', {\n error: error.toString()\n }, 'error');\n }\n });\n _defineProperty(this, \"calibrateAnimate\", timestamp => {\n if (this.animationStartTimestamp === undefined) {\n this.animationStartTimestamp = timestamp;\n }\n this.deviation = timestamp - this.animationStartTimestamp;\n if (this.animationId) {\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n }\n });\n _defineProperty(this, \"handleStatus\", connectionStatus => {\n log('rtm status update', {\n state: connectionStatus.state,\n reason: connectionStatus.reason\n });\n if (connectionStatus.state === 'RECONNECTING' && this.reconnectTimeout === null) {\n this.emit('connectionStatusChange', 'RECONNECTING');\n this.reconnectTimeout = window.setTimeout(() => {\n this.emit('error', 'reconnecting timeout');\n this.emit('connectionStatusChange', 'DISCONNECTED');\n }, 30 * 1000);\n } else if (connectionStatus.state === 'CONNECTED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('connectionStatusChange', 'CONNECTED');\n } else if (connectionStatus.state === 'FAILED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('error', `rtm connection failed, ${connectionStatus.reason}`);\n this.emit('connectionStatusChange', 'DISCONNECTED');\n } else if (connectionStatus.state === 'CONNECTING') {\n this.emit('connectionStatusChange', 'CONNECTING');\n }\n });\n _defineProperty(this, \"handlePresence\", evt => {\n if (evt.channelName === this.roomChannel()) {\n if (evt.eventType === 'REMOTE_JOIN') {\n this.emit('userJoin', evt.publisher);\n } else if (evt.eventType === 'REMOTE_LEAVE') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'REMOTE_TIMEOUT') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'INTERVAL') {\n // evt.interval.join.users\n }\n }\n });\n this.rtmClient = rtmClient;\n }\n roomChannel() {\n return `r_${this.roomId}`;\n }\n userChannel(userId) {\n if (userId.length > 16) {\n userId = `${cyrb53(userId)}`;\n }\n return `${this.roomChannel()}_u_${userId}`;\n }\n\n /**\n * \u91CD\u65B0\u8BA2\u9605\u9891\u9053\n */\n async resubscribe() {\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n }\n }\n async initialize(roomId, userId) {\n window.clearInterval(this.intervalId);\n this.roomId = roomId;\n this.userId = userId;\n this.rtmClient.addEventListener('message', this.handleRtmMessage);\n this.rtmClient.addEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.addEventListener('status', this.handleStatus);\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n throw error;\n }\n this.intervalId = setInterval(() => {\n const msg = this.cachedMessages.shift();\n if (msg) {\n const channel = msg.target ? this.userChannel(msg.target) : this.roomChannel();\n this.rtmClient.publish(channel, msg.buffer, {\n customType: msg.customType\n }).catch(error => {\n log('rtm publish failed', {\n channel,\n code: error.code\n }, 'warn');\n this.emit('error', `rtm publish fail, ${error}`);\n });\n }\n }, 32);\n }\n async dispose() {\n this.rtmClient.removeEventListener('message', this.handleRtmMessage);\n this.rtmClient.removeEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.removeEventListener('status', this.handleStatus);\n await this.rtmClient.unsubscribe(this.roomChannel());\n await this.rtmClient.unsubscribe(this.userChannel(this.userId));\n window.clearInterval(this.intervalId);\n }\n isForgeRoomChannel(channel) {\n return channel === this.roomChannel() || channel === this.userChannel(this.userId);\n }\n receiveChunkMessage(msg, publisher, isRoomChannel) {\n if (msg.length === 1) {\n this.emit('message', msg.buf, publisher, msg.customType, isRoomChannel);\n return;\n }\n const chunks = this.chunkedMessages.get(msg.session) || [];\n chunks.push(msg);\n if (chunks.length === msg.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n this.emit('message', buffer, publisher, msg.customType, isRoomChannel);\n this.chunkedMessages.delete(msg.session);\n } else {\n this.chunkedMessages.set(msg.session, chunks);\n }\n }\n publish(buf, customType) {\n let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';\n const chunkStep = 24;\n const session = uuidv4();\n // \u6D88\u606F\u5305\u4F53\u79EF, \u5355\u4F4D kb\n const size = buf.length * Uint8Array.BYTES_PER_ELEMENT / 1024;\n if (size < chunkStep) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf,\n length: 1,\n index: 0,\n session\n }, target, customType));\n } else {\n const chunkSize = chunkStep * 1024 / Uint8Array.BYTES_PER_ELEMENT;\n const len = Math.ceil(size / chunkStep);\n let index = 0;\n while (index < len) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf.slice(index * chunkSize, (index + 1) * chunkSize),\n length: len,\n index: index,\n session\n }, target, customType));\n index += 1;\n }\n }\n }\n async userList() {\n const output = new Set();\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false\n });\n let nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n while (nextPage) {\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false,\n page: nextPage\n });\n nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n }\n return output;\n }\n async historyMessage(_begin, _end) {\n return null;\n }\n}", "export const cyrb53 = function (str) {\n let seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n let h1 = 0xdeadbeef ^ seed,\n h2 = 0x41c6ce57 ^ seed;\n for (let i = 0, ch; i < str.length; i++) {\n ch = str.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);\n h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);\n h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);\n h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);\n return 4294967296 * (2097151 & h2) + (h1 >>> 0);\n};", "function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nexport class ChunkedUpdateMessage {\n static fromObject(obj, target, customType) {\n const msg = new ChunkedUpdateMessage();\n msg.target = target;\n msg.customType = customType;\n const encoder = new TextEncoder();\n const sessionBuf = encoder.encode(obj.session);\n\n // header \u6309\u987A\u5E8F\u6307\u793A buf, session, target, customType \u90E8\u5206\u7684 uint8 \u957F\u5EA6\n msg.header = new DataView(new Uint8Array(10).buffer);\n msg.header.setUint32(0, obj.buf.length, false);\n msg.header.setUint32(4, sessionBuf.length, false);\n msg.header.setUint8(8, obj.index);\n msg.header.setUint8(9, obj.length);\n msg.buffer = new Uint8Array(obj.buf.length + sessionBuf.length + msg.header.buffer.byteLength);\n let len = 0;\n msg.buffer.set(new Uint8Array(msg.header.buffer), len);\n len += msg.header.buffer.byteLength;\n msg.buffer.set(obj.buf, len);\n len += obj.buf.length;\n msg.buffer.set(sessionBuf, len);\n return msg;\n }\n static fromBuffer(buf, target, customType) {\n const msg = new ChunkedUpdateMessage();\n msg.header = new DataView(buf.slice(0, 10).buffer);\n msg.buffer = buf.slice(10);\n msg.target = target;\n msg.customType = customType;\n return msg;\n }\n get buf() {\n const len = this.header.getInt32(0);\n return this.buffer.slice(0, len);\n }\n get index() {\n return this.header.getUint8(8);\n }\n get length() {\n return this.header.getUint8(9);\n }\n get session() {\n const start = this.header.getInt32(0);\n const sessionBuf = this.buffer.slice(start, start + this.header.getInt32(4));\n const textDecoder = new TextDecoder();\n return textDecoder.decode(sessionBuf);\n }\n constructor() {\n _defineProperty(this, \"target\", void 0);\n _defineProperty(this, \"customType\", void 0);\n _defineProperty(this, \"buffer\", void 0);\n _defineProperty(this, \"header\", void 0);\n }\n}", "function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nimport { log } from '@netless/forge-room';\nimport EventEmitter from 'eventemitter3';\nimport { v4 as uuidv4 } from 'uuid';\nimport { cyrb53 } from './utils';\nimport { ChunkedUpdateMessage } from './ChunkedUpdateMessage';\nexport class RTMProvider_2_2 extends EventEmitter {\n get calibrationTimestamp() {\n return this.rtmTimestamp + this.deviation;\n }\n constructor(rtmClient) {\n super();\n _defineProperty(this, \"rtmClient\", void 0);\n _defineProperty(this, \"roomId\", void 0);\n _defineProperty(this, \"userId\", void 0);\n _defineProperty(this, \"reconnectTimeout\", null);\n _defineProperty(this, \"chunkedMessages\", new Map());\n _defineProperty(this, \"cachedMessages\", []);\n _defineProperty(this, \"lastCachedMessageReportTime\", 0);\n _defineProperty(this, \"intervalId\", null);\n _defineProperty(this, \"deviation\", 0);\n _defineProperty(this, \"rtmTimestamp\", 0);\n _defineProperty(this, \"animationStartTimestamp\", void 0);\n _defineProperty(this, \"animationId\", void 0);\n _defineProperty(this, \"handleRtmMessage\", evt => {\n try {\n const isRoomChannel = evt.channelName.indexOf('_u_') < 0;\n if (!(evt.message instanceof Uint8Array) || !this.isForgeRoomChannel(evt.channelName)) {\n return;\n }\n if (this.animationId) {\n cancelAnimationFrame(this.animationId);\n this.animationStartTimestamp = undefined;\n this.animationId = undefined;\n this.deviation = 0;\n }\n this.rtmTimestamp = evt.timestamp || Date.now();\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n this.receiveChunkMessage(ChunkedUpdateMessage.fromBuffer(evt.message, '', evt.customType), evt.publisher, isRoomChannel);\n } catch (e) {\n log('rtm handle message error', {\n error: e.toString()\n }, 'error');\n }\n });\n _defineProperty(this, \"calibrateAnimate\", timestamp => {\n if (this.animationStartTimestamp === undefined) {\n this.animationStartTimestamp = timestamp;\n }\n this.deviation = timestamp - this.animationStartTimestamp;\n if (this.animationId) {\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n }\n });\n _defineProperty(this, \"handleStatus\", connectionStatus => {\n log('rtm status update', {\n state: connectionStatus.state,\n reason: connectionStatus.reason,\n rtm: '2.2'\n });\n if (connectionStatus.state === 'RECONNECTING' && this.reconnectTimeout === null) {\n this.emit('connectionStatusChange', 'RECONNECTING');\n this.emit('userLeave', this.userId);\n this.reconnectTimeout = window.setTimeout(() => {\n this.emit('error', 'reconnecting timeout');\n this.emit('connectionStatusChange', 'DISCONNECTED');\n }, 30 * 1000);\n } else if (connectionStatus.state === 'CONNECTED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('connectionStatusChange', 'CONNECTED');\n this.emit('userJoin', this.userId);\n } else if (connectionStatus.state === 'FAILED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('error', `rtm connection failed, ${connectionStatus.reason}`);\n this.emit('connectionStatusChange', 'DISCONNECTED');\n this.emit('userLeave', this.userId);\n } else if (connectionStatus.state === 'CONNECTING') {\n this.emit('connectionStatusChange', 'CONNECTING');\n this.emit('userLeave', this.userId);\n }\n });\n _defineProperty(this, \"handlePresence\", evt => {\n if (evt.channelName === this.roomChannel()) {\n if (evt.eventType === 'REMOTE_JOIN') {\n this.emit('userJoin', evt.publisher);\n } else if (evt.eventType === 'REMOTE_LEAVE') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'REMOTE_TIMEOUT') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'INTERVAL') {\n // evt.interval.join.users\n }\n }\n });\n this.rtmClient = rtmClient;\n }\n roomChannel() {\n return `r_${this.roomId}`;\n }\n userChannel(userId) {\n if (userId.length > 16) {\n userId = `${cyrb53(userId)}`;\n }\n return `${this.roomChannel()}_u_${userId}`;\n }\n async initialize(roomId, userId) {\n window.clearInterval(this.intervalId);\n this.roomId = roomId;\n this.userId = userId;\n this.rtmClient.addEventListener('message', this.handleRtmMessage);\n this.rtmClient.addEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.addEventListener('status', this.handleStatus);\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString(),\n rtm: '2.2'\n }, 'error');\n throw error;\n }\n this.intervalId = setInterval(() => {\n const msg = this.cachedMessages.shift();\n if (msg) {\n const channel = msg.target ? this.userChannel(msg.target) : this.roomChannel();\n this.rtmClient.publish(channel, msg.buffer, {\n customType: msg.customType,\n storeInHistory: true\n }).catch(error => {\n log('rtm publish failed', {\n channel,\n code: error.code,\n rtm: '2.2'\n }, 'warn');\n this.emit('error', `rtm publish fail, ${error}`);\n });\n }\n }, 32);\n }\n\n /**\n * \u91CD\u65B0\u8BA2\u9605\u9891\u9053\n */\n async resubscribe() {\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n }\n }\n async dispose() {\n this.rtmClient.removeEventListener('message', this.handleRtmMessage);\n this.rtmClient.removeEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.removeEventListener('status', this.handleStatus);\n await this.rtmClient.unsubscribe(this.roomChannel());\n await this.rtmClient.unsubscribe(this.userChannel(this.userId));\n window.clearInterval(this.intervalId);\n }\n isForgeRoomChannel(channel) {\n return channel === this.roomChannel() || channel === this.userChannel(this.userId);\n }\n receiveChunkMessage(msg, publisher, isRoomChannel) {\n if (msg.length === 1) {\n this.emit('message', msg.buf, publisher, msg.customType, isRoomChannel);\n return;\n }\n const chunks = this.chunkedMessages.get(msg.session) || [];\n chunks.push(msg);\n if (chunks.length === msg.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n this.emit('message', buffer, publisher, msg.customType, isRoomChannel);\n this.chunkedMessages.delete(msg.session);\n } else {\n this.chunkedMessages.set(msg.session, chunks);\n }\n }\n publish(buf, customType) {\n let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';\n if (this.cachedMessages.length > 150 && Date.now() - this.lastCachedMessageReportTime > 5000) {\n log(`rtm cached message too many: ${this.cachedMessages.length}`, {}, 'warn');\n this.lastCachedMessageReportTime = Date.now();\n }\n const chunkStep = 24;\n const session = uuidv4();\n // \u6D88\u606F\u5305\u4F53\u79EF, \u5355\u4F4D kb\n const size = buf.length * Uint8Array.BYTES_PER_ELEMENT / 1024;\n if (size < chunkStep) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf,\n length: 1,\n index: 0,\n session\n }, target, customType));\n } else {\n const chunkSize = chunkStep * 1024 / Uint8Array.BYTES_PER_ELEMENT;\n const len = Math.ceil(size / chunkStep);\n let index = 0;\n while (index < len) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf.slice(index * chunkSize, (index + 1) * chunkSize),\n length: len,\n index: index,\n session\n }, target, customType));\n index += 1;\n }\n }\n }\n async userList() {\n const output = new Set();\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false\n });\n let nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n while (nextPage) {\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false,\n page: nextPage\n });\n nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n }\n return output;\n }\n async fetchHistoryMessage(begin, end, channel) {\n let start = begin;\n let continueFetch = true;\n const output = [];\n while (continueFetch) {\n const response = await this.rtmClient.history.getMessages(channel, 'MESSAGE', {\n start: start,\n end: end\n });\n if (response.newStart !== 0) {\n start = response.newStart;\n } else {\n continueFetch = false;\n }\n const chunkedMessages = new Map();\n for (const msg of response.messageList) {\n const chunked = ChunkedUpdateMessage.fromBuffer(msg.message, msg.publisher, msg.customType);\n if (chunked.length === 1) {\n output.push({\n buf: chunked.buf,\n publisher: msg.publisher,\n customType: msg.customType,\n isRoomChannel: channel === this.roomChannel()\n });\n } else {\n const chunks = chunkedMessages.get(chunked.session) || [];\n chunks.push(chunked);\n if (chunks.length === chunked.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n output.push({\n buf: buffer,\n publisher: msg.publisher,\n customType: msg.customType,\n isRoomChannel: channel === this.roomChannel()\n });\n chunkedMessages.delete(chunked.session);\n } else {\n chunkedMessages.set(chunked.session, chunks);\n }\n }\n }\n }\n return output;\n }\n async historyMessage(begin, end) {\n try {\n const roomMessages = await this.fetchHistoryMessage(end, begin, this.roomChannel());\n const userMessages = await this.fetchHistoryMessage(end, begin, this.userChannel(this.userId));\n return roomMessages.concat(userMessages);\n } catch (error) {\n this.emit('error', 'rtm historyMessage not support: ' + error);\n console.warn('rtm historyMessage not support: ' + error);\n return null;\n }\n }\n}"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,wBAAoB;AACpB,2BAAyB;AACzB,kBAA6B;;;ACLtB,IAAM,SAAS,SAAU,KAAK;AACnC,MAAI,OAAO,UAAU,SAAS,KAAK,UAAU,CAAC,MAAM,SAAY,UAAU,CAAC,IAAI;AAC/E,MAAI,KAAK,aAAa,MACpB,KAAK,aAAa;AACpB,WAAS,IAAI,GAAG,IAAI,IAAI,IAAI,QAAQ,KAAK;AACvC,SAAK,IAAI,WAAW,CAAC;AACrB,SAAK,KAAK,KAAK,KAAK,IAAI,UAAU;AAClC,SAAK,KAAK,KAAK,KAAK,IAAI,UAAU;AAAA,EACpC;AACA,OAAK,KAAK,KAAK,KAAK,OAAO,IAAI,UAAU;AACzC,QAAM,KAAK,KAAK,KAAK,OAAO,IAAI,UAAU;AAC1C,OAAK,KAAK,KAAK,KAAK,OAAO,IAAI,UAAU;AACzC,QAAM,KAAK,KAAK,KAAK,OAAO,IAAI,UAAU;AAC1C,SAAO,cAAc,UAAU,OAAO,OAAO;AAC/C;;;ACdA,SAAS,gBAAgB,GAAG,GAAG,GAAG;AAAE,UAAQ,IAAI,eAAe,CAAC,MAAM,IAAI,OAAO,eAAe,GAAG,GAAG,EAAE,OAAO,GAAG,YAAY,MAAI,cAAc,MAAI,UAAU,KAAG,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG;AAAG;AACnL,SAAS,eAAe,GAAG;AAAE,MAAI,IAAI,aAAa,GAAG,QAAQ;AAAG,SAAO,YAAY,OAAO,IAAI,IAAI,IAAI;AAAI;AAC1G,SAAS,aAAa,GAAG,GAAG;AAAE,MAAI,YAA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MAAM,KAAK,oBAAoB,KAAK,OAAO,KAAK,YAAY,CAAC;AAClF,YAAM,eAAe,MAAM,KAAK,oBAAoB,KAAK,OAAO,KAAK,YAAY,KAAK,MAAM,CAAC;AAC7F,aAAO,aAAa,OAAO,YAAY;AAAA,IACzC,SAAS,OAAO;AACd,WAAK,KAAK,SAAS,qCAAqC,KAAK;AAC7D,cAAQ,KAAK,qCAAqC,KAAK;AACvD,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
|
6
|
-
"names": ["_defineProperty", "_toPropertyKey", "_toPrimitive", "EventEmitter", "uuidv4", "result", "import_forge_room", "import_eventemitter3", "import_uuid", "_defineProperty", "_toPropertyKey", "_toPrimitive", "EventEmitter", "uuidv4", "result", "output"]
|
|
4
|
+
"sourcesContent": ["export { RTMProvider_2_1 } from './RTM_2_1';\nexport { RTMProvider_2_2 } from './RTM_2_2';", "function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nimport { log } from '@netless/forge-room';\nimport EventEmitter from 'eventemitter3';\nimport { v4 as uuidv4 } from 'uuid';\nimport { cyrb53 } from './utils';\nimport { ChunkedUpdateMessage } from './ChunkedUpdateMessage';\nexport class RTMProvider_2_1 extends EventEmitter {\n get calibrationTimestamp() {\n return this.rtmTimestamp + this.deviation;\n }\n constructor(rtmClient) {\n super();\n _defineProperty(this, \"rtmClient\", void 0);\n _defineProperty(this, \"roomId\", void 0);\n _defineProperty(this, \"userId\", void 0);\n _defineProperty(this, \"reconnectTimeout\", null);\n _defineProperty(this, \"chunkedMessages\", new Map());\n _defineProperty(this, \"cachedMessages\", []);\n _defineProperty(this, \"intervalId\", null);\n _defineProperty(this, \"deviation\", 0);\n _defineProperty(this, \"rtmTimestamp\", 0);\n _defineProperty(this, \"animationStartTimestamp\", void 0);\n _defineProperty(this, \"animationId\", void 0);\n _defineProperty(this, \"cachedWritable\", new Map());\n _defineProperty(this, \"isInitialized\", false);\n _defineProperty(this, \"handleRtmMessage\", evt => {\n try {\n const isRoomChannel = evt.channelName.indexOf('_u_') < 0;\n if (!(evt.message instanceof Uint8Array) || !this.isForgeRoomChannel(evt.channelName)) {\n return;\n }\n if (this.animationId) {\n cancelAnimationFrame(this.animationId);\n this.animationStartTimestamp = undefined;\n this.animationId = undefined;\n this.deviation = 0;\n }\n this.rtmTimestamp = evt.timestamp || Date.now();\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n // console.log(\"rtm timestamp\", evt.timestamp, \"calibrationTimestamp\", this.calibrationTimestamp);\n this.receiveChunkMessage(ChunkedUpdateMessage.fromBuffer(evt.message, '', evt.customType), evt.publisher, isRoomChannel);\n } catch (error) {\n log('rtm handle message error', {\n error: error.toString()\n }, 'error');\n }\n });\n _defineProperty(this, \"calibrateAnimate\", timestamp => {\n if (this.animationStartTimestamp === undefined) {\n this.animationStartTimestamp = timestamp;\n }\n this.deviation = timestamp - this.animationStartTimestamp;\n if (this.animationId) {\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n }\n });\n _defineProperty(this, \"handleStorageEvent\", storageData => {\n if (storageData.channelName === this.writableChannel()) {\n // \u5904\u7406 writable \u72B6\u6001\u53D8\u66F4\uFF0C\u7EC4\u7EC7\u6240\u6709\u4EBA\u7684 writable \u72B6\u6001\n const writableStates = {};\n const metadata = storageData.data.metadata;\n for (const userId in metadata) {\n const value = metadata[userId].value;\n writableStates[userId] = value === 'true';\n }\n this.emit('writableChanged', writableStates);\n }\n });\n _defineProperty(this, \"handleStatus\", connectionStatus => {\n log('rtm status update', {\n state: connectionStatus.state,\n reason: connectionStatus.reason\n });\n if (connectionStatus.state === 'RECONNECTING' && this.reconnectTimeout === null) {\n this.emit('connectionStatusChange', 'RECONNECTING');\n this.reconnectTimeout = window.setTimeout(() => {\n this.emit('error', 'reconnecting timeout');\n this.emit('connectionStatusChange', 'DISCONNECTED');\n }, 30 * 1000);\n } else if (connectionStatus.state === 'CONNECTED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('connectionStatusChange', 'CONNECTED');\n } else if (connectionStatus.state === 'FAILED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('error', `rtm connection failed, ${connectionStatus.reason}`);\n this.emit('connectionStatusChange', 'DISCONNECTED');\n } else if (connectionStatus.state === 'CONNECTING') {\n this.emit('connectionStatusChange', 'CONNECTING');\n }\n });\n _defineProperty(this, \"handlePresence\", evt => {\n if (evt.channelName === this.roomChannel()) {\n if (evt.eventType === 'REMOTE_JOIN') {\n this.emit('userJoin', evt.publisher);\n } else if (evt.eventType === 'REMOTE_LEAVE') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'REMOTE_TIMEOUT') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'INTERVAL') {\n // evt.interval.join.users\n }\n }\n });\n this.rtmClient = rtmClient;\n }\n roomChannel() {\n return `r_${this.roomId}`;\n }\n userChannel(userId) {\n if (userId.length > 16) {\n userId = `${cyrb53(userId)}`;\n }\n return `${this.roomChannel()}_u_${userId}`;\n }\n writableChannel() {\n return 'userWritable';\n }\n\n /**\n * \u91CD\u65B0\u8BA2\u9605\u9891\u9053\n */\n async resubscribe() {\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n await this.rtmClient.subscribe(this.writableChannel(), {\n withMetadata: true\n });\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n }\n }\n async initialize(roomId, userId) {\n window.clearInterval(this.intervalId);\n this.roomId = roomId;\n this.userId = userId;\n this.rtmClient.addEventListener('message', this.handleRtmMessage);\n this.rtmClient.addEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.addEventListener('status', this.handleStatus);\n this.rtmClient.addEventListener('storage', this.handleStorageEvent);\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n await this.rtmClient.subscribe(this.writableChannel(), {\n withMetadata: true\n });\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n throw error;\n }\n this.isInitialized = true;\n if (this.cachedWritable.size > 0) {\n const writableData = Array.from(this.cachedWritable.entries()).map(_ref => {\n let [userId, writable] = _ref;\n return {\n key: userId,\n value: writable ? 'true' : 'false'\n };\n });\n await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), 'MESSAGE', writableData);\n this.cachedWritable.clear();\n }\n this.intervalId = setInterval(() => {\n const msg = this.cachedMessages.shift();\n if (msg) {\n const channel = msg.target ? this.userChannel(msg.target) : this.roomChannel();\n this.rtmClient.publish(channel, msg.buffer, {\n customType: msg.customType\n }).catch(error => {\n log('rtm publish failed', {\n channel,\n code: error.code\n }, 'warn');\n this.emit('error', `rtm publish fail, ${error}`);\n });\n }\n }, 32);\n }\n async dispose() {\n this.rtmClient.removeEventListener('message', this.handleRtmMessage);\n this.rtmClient.removeEventListener('presence', this.handlePresence);\n this.rtmClient.removeEventListener('storage', this.handleStorageEvent);\n // @ts-ignore\n this.rtmClient.removeEventListener('status', this.handleStatus);\n await this.rtmClient.unsubscribe(this.roomChannel());\n await this.rtmClient.unsubscribe(this.userChannel(this.userId));\n await this.rtmClient.unsubscribe(this.writableChannel());\n window.clearInterval(this.intervalId);\n }\n isForgeRoomChannel(channel) {\n return channel === this.roomChannel() || channel === this.userChannel(this.userId);\n }\n receiveChunkMessage(msg, publisher, isRoomChannel) {\n if (msg.length === 1) {\n this.emit('message', msg.buf, publisher, msg.customType, isRoomChannel);\n return;\n }\n const chunks = this.chunkedMessages.get(msg.session) || [];\n chunks.push(msg);\n if (chunks.length === msg.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n this.emit('message', buffer, publisher, msg.customType, isRoomChannel);\n this.chunkedMessages.delete(msg.session);\n } else {\n this.chunkedMessages.set(msg.session, chunks);\n }\n }\n publish(buf, customType) {\n let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';\n const chunkStep = 24;\n const session = uuidv4();\n // \u6D88\u606F\u5305\u4F53\u79EF, \u5355\u4F4D kb\n const size = buf.length * Uint8Array.BYTES_PER_ELEMENT / 1024;\n if (size < chunkStep) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf,\n length: 1,\n index: 0,\n session\n }, target, customType));\n } else {\n const chunkSize = chunkStep * 1024 / Uint8Array.BYTES_PER_ELEMENT;\n const len = Math.ceil(size / chunkStep);\n let index = 0;\n while (index < len) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf.slice(index * chunkSize, (index + 1) * chunkSize),\n length: len,\n index: index,\n session\n }, target, customType));\n index += 1;\n }\n }\n }\n async userList() {\n const output = new Set();\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false\n });\n let nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n while (nextPage) {\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false,\n page: nextPage\n });\n nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n }\n return output;\n }\n async historyMessage(_begin, _end) {\n return null;\n }\n async setUserWritable(writable, userId) {\n // \u7F13\u5B58\u7684\u4F5C\u7528\u662F\u52A0\u5165\u9891\u9053\u4E4B\u540E\u624D\u80FD\u8C03\u7528 setChannelMetadata\uFF0C\u6240\u4EE5\u7F13\u5B58\u5E94\u8BE5\u5728\u52A0\u5165\u9891\u9053\u6210\u529F\u540E\u5220\u9664\n const targetUserId = userId || this.userId;\n if (!this.isInitialized) {\n this.cachedWritable.set(targetUserId, writable);\n return;\n }\n await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), 'MESSAGE', [{\n key: targetUserId,\n value: writable ? 'true' : 'false'\n }]);\n }\n async getUserWritable(userId) {\n const targetUserId = userId || this.userId;\n try {\n const channelMeta = await this.rtmClient.storage.getChannelMetadata(this.writableChannel(), 'MESSAGE');\n const value = channelMeta.metadata[targetUserId]?.value;\n return value === 'true';\n } catch (error) {\n log('getUserWritable failed', {\n error: error.toString(),\n userId: targetUserId\n }, 'warn');\n return true;\n }\n }\n}", "export const cyrb53 = function (str) {\n let seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n let h1 = 0xdeadbeef ^ seed,\n h2 = 0x41c6ce57 ^ seed;\n for (let i = 0, ch; i < str.length; i++) {\n ch = str.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);\n h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);\n h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);\n h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);\n return 4294967296 * (2097151 & h2) + (h1 >>> 0);\n};", "function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nexport class ChunkedUpdateMessage {\n static fromObject(obj, target, customType) {\n const msg = new ChunkedUpdateMessage();\n msg.target = target;\n msg.customType = customType;\n const encoder = new TextEncoder();\n const sessionBuf = encoder.encode(obj.session);\n\n // header \u6309\u987A\u5E8F\u6307\u793A buf, session, target, customType \u90E8\u5206\u7684 uint8 \u957F\u5EA6\n msg.header = new DataView(new Uint8Array(10).buffer);\n msg.header.setUint32(0, obj.buf.length, false);\n msg.header.setUint32(4, sessionBuf.length, false);\n msg.header.setUint8(8, obj.index);\n msg.header.setUint8(9, obj.length);\n msg.buffer = new Uint8Array(obj.buf.length + sessionBuf.length + msg.header.buffer.byteLength);\n let len = 0;\n msg.buffer.set(new Uint8Array(msg.header.buffer), len);\n len += msg.header.buffer.byteLength;\n msg.buffer.set(obj.buf, len);\n len += obj.buf.length;\n msg.buffer.set(sessionBuf, len);\n return msg;\n }\n static fromBuffer(buf, target, customType) {\n const msg = new ChunkedUpdateMessage();\n msg.header = new DataView(buf.slice(0, 10).buffer);\n msg.buffer = buf.slice(10);\n msg.target = target;\n msg.customType = customType;\n return msg;\n }\n get buf() {\n const len = this.header.getInt32(0);\n return this.buffer.slice(0, len);\n }\n get index() {\n return this.header.getUint8(8);\n }\n get length() {\n return this.header.getUint8(9);\n }\n get session() {\n const start = this.header.getInt32(0);\n const sessionBuf = this.buffer.slice(start, start + this.header.getInt32(4));\n const textDecoder = new TextDecoder();\n return textDecoder.decode(sessionBuf);\n }\n constructor() {\n _defineProperty(this, \"target\", void 0);\n _defineProperty(this, \"customType\", void 0);\n _defineProperty(this, \"buffer\", void 0);\n _defineProperty(this, \"header\", void 0);\n }\n}", "function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nimport { log } from '@netless/forge-room';\nimport EventEmitter from 'eventemitter3';\nimport { v4 as uuidv4 } from 'uuid';\nimport { cyrb53 } from './utils';\nimport { ChunkedUpdateMessage } from './ChunkedUpdateMessage';\nexport class RTMProvider_2_2 extends EventEmitter {\n get calibrationTimestamp() {\n return this.rtmTimestamp + this.deviation;\n }\n constructor(rtmClient) {\n super();\n _defineProperty(this, \"rtmClient\", void 0);\n _defineProperty(this, \"roomId\", void 0);\n _defineProperty(this, \"userId\", void 0);\n _defineProperty(this, \"reconnectTimeout\", null);\n _defineProperty(this, \"chunkedMessages\", new Map());\n _defineProperty(this, \"cachedMessages\", []);\n _defineProperty(this, \"lastCachedMessageReportTime\", 0);\n _defineProperty(this, \"intervalId\", null);\n _defineProperty(this, \"deviation\", 0);\n _defineProperty(this, \"rtmTimestamp\", 0);\n _defineProperty(this, \"animationStartTimestamp\", void 0);\n _defineProperty(this, \"animationId\", void 0);\n _defineProperty(this, \"cachedWritable\", new Map());\n _defineProperty(this, \"isInitialized\", false);\n _defineProperty(this, \"handleRtmMessage\", evt => {\n try {\n const isRoomChannel = evt.channelName.indexOf('_u_') < 0;\n if (!(evt.message instanceof Uint8Array) || !this.isForgeRoomChannel(evt.channelName)) {\n return;\n }\n if (this.animationId) {\n cancelAnimationFrame(this.animationId);\n this.animationStartTimestamp = undefined;\n this.animationId = undefined;\n this.deviation = 0;\n }\n this.rtmTimestamp = evt.timestamp || Date.now();\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n this.receiveChunkMessage(ChunkedUpdateMessage.fromBuffer(evt.message, '', evt.customType), evt.publisher, isRoomChannel);\n } catch (e) {\n log('rtm handle message error', {\n error: e.toString()\n }, 'error');\n }\n });\n _defineProperty(this, \"calibrateAnimate\", timestamp => {\n if (this.animationStartTimestamp === undefined) {\n this.animationStartTimestamp = timestamp;\n }\n this.deviation = timestamp - this.animationStartTimestamp;\n if (this.animationId) {\n this.animationId = requestAnimationFrame(this.calibrateAnimate);\n }\n });\n _defineProperty(this, \"handleStorageEvent\", storageData => {\n if (storageData.channelName === this.writableChannel()) {\n // \u5904\u7406 writable \u72B6\u6001\u53D8\u66F4\uFF0C\u7EC4\u7EC7\u6240\u6709\u4EBA\u7684 writable \u72B6\u6001\n const writableStates = {};\n const metadata = storageData.data.metadata;\n for (const userId in metadata) {\n const value = metadata[userId].value;\n writableStates[userId] = value === 'true';\n }\n this.emit('writableChanged', writableStates);\n }\n });\n _defineProperty(this, \"handleStatus\", connectionStatus => {\n log('rtm status update', {\n state: connectionStatus.state,\n reason: connectionStatus.reason,\n rtm: '2.2'\n });\n if (connectionStatus.state === 'RECONNECTING' && this.reconnectTimeout === null) {\n this.emit('connectionStatusChange', 'RECONNECTING');\n this.emit('userLeave', this.userId);\n this.reconnectTimeout = window.setTimeout(() => {\n this.emit('error', 'reconnecting timeout');\n this.emit('connectionStatusChange', 'DISCONNECTED');\n }, 30 * 1000);\n } else if (connectionStatus.state === 'CONNECTED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('connectionStatusChange', 'CONNECTED');\n this.emit('userJoin', this.userId);\n } else if (connectionStatus.state === 'FAILED') {\n window.clearTimeout(this.reconnectTimeout);\n this.emit('error', `rtm connection failed, ${connectionStatus.reason}`);\n this.emit('connectionStatusChange', 'DISCONNECTED');\n this.emit('userLeave', this.userId);\n } else if (connectionStatus.state === 'CONNECTING') {\n this.emit('connectionStatusChange', 'CONNECTING');\n this.emit('userLeave', this.userId);\n }\n });\n _defineProperty(this, \"handlePresence\", evt => {\n if (evt.channelName === this.roomChannel()) {\n if (evt.eventType === 'REMOTE_JOIN') {\n this.emit('userJoin', evt.publisher);\n } else if (evt.eventType === 'REMOTE_LEAVE') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'REMOTE_TIMEOUT') {\n this.emit('userLeave', evt.publisher);\n } else if (evt.eventType === 'INTERVAL') {\n // evt.interval.join.users\n }\n }\n });\n this.rtmClient = rtmClient;\n }\n roomChannel() {\n return `r_${this.roomId}`;\n }\n writableChannel() {\n return `${this.roomChannel()}_uw`;\n }\n userChannel(userId) {\n if (userId.length > 16) {\n userId = `${cyrb53(userId)}`;\n }\n return `${this.roomChannel()}_u_${userId}`;\n }\n async initialize(roomId, userId) {\n window.clearInterval(this.intervalId);\n this.roomId = roomId;\n this.userId = userId;\n this.rtmClient.addEventListener('message', this.handleRtmMessage);\n this.rtmClient.addEventListener('presence', this.handlePresence);\n // @ts-ignore\n this.rtmClient.addEventListener('status', this.handleStatus);\n this.rtmClient.addEventListener('storage', this.handleStorageEvent);\n try {\n await this.rtmClient.subscribe(this.roomChannel(), {\n withPresence: true\n });\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n await this.rtmClient.subscribe(this.writableChannel(), {\n withMetadata: true\n });\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString(),\n rtm: '2.2'\n }, 'error');\n throw error;\n }\n this.intervalId = setInterval(() => {\n const msg = this.cachedMessages.shift();\n if (msg) {\n const channel = msg.target ? this.userChannel(msg.target) : this.roomChannel();\n this.rtmClient.publish(channel, msg.buffer, {\n customType: msg.customType,\n storeInHistory: true\n }).catch(error => {\n log('rtm publish failed', {\n channel,\n code: error.code,\n rtm: '2.2'\n }, 'warn');\n this.emit('error', `rtm publish fail, ${error}`);\n });\n }\n }, 32);\n this.isInitialized = true;\n if (this.cachedWritable.size > 0) {\n const writableData = Array.from(this.cachedWritable.entries()).map(_ref => {\n let [userId, writable] = _ref;\n return {\n key: userId,\n value: writable ? 'true' : 'false'\n };\n });\n await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), 'MESSAGE', writableData);\n this.cachedWritable.clear();\n }\n }\n\n /**\n * \u91CD\u65B0\u8BA2\u9605\u9891\u9053\n */\n async resubscribe() {\n try {\n await this.rtmClient.subscribe(this.roomChannel());\n await this.rtmClient.subscribe(this.userChannel(this.userId));\n await this.rtmClient.subscribe(this.writableChannel(), {\n withMetadata: true\n });\n } catch (error) {\n this.emit('error', `rtm subscribe fail, ${error}`);\n log('rtm subscribe fail', {\n error: error.toString()\n }, 'error');\n }\n }\n async dispose() {\n this.rtmClient.removeEventListener('message', this.handleRtmMessage);\n this.rtmClient.removeEventListener('presence', this.handlePresence);\n this.rtmClient.removeEventListener('storage', this.handleStorageEvent);\n // @ts-ignore\n this.rtmClient.removeEventListener('status', this.handleStatus);\n await this.rtmClient.unsubscribe(this.roomChannel());\n await this.rtmClient.unsubscribe(this.userChannel(this.userId));\n await this.rtmClient.unsubscribe(this.writableChannel());\n window.clearInterval(this.intervalId);\n }\n isForgeRoomChannel(channel) {\n return channel === this.roomChannel() || channel === this.userChannel(this.userId);\n }\n receiveChunkMessage(msg, publisher, isRoomChannel) {\n if (msg.length === 1) {\n this.emit('message', msg.buf, publisher, msg.customType, isRoomChannel);\n return;\n }\n const chunks = this.chunkedMessages.get(msg.session) || [];\n chunks.push(msg);\n if (chunks.length === msg.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n this.emit('message', buffer, publisher, msg.customType, isRoomChannel);\n this.chunkedMessages.delete(msg.session);\n } else {\n this.chunkedMessages.set(msg.session, chunks);\n }\n }\n publish(buf, customType) {\n let target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';\n if (this.cachedMessages.length > 150 && Date.now() - this.lastCachedMessageReportTime > 5000) {\n log(`rtm cached message too many: ${this.cachedMessages.length}`, {}, 'warn');\n this.lastCachedMessageReportTime = Date.now();\n }\n const chunkStep = 24;\n const session = uuidv4();\n // \u6D88\u606F\u5305\u4F53\u79EF, \u5355\u4F4D kb\n const size = buf.length * Uint8Array.BYTES_PER_ELEMENT / 1024;\n if (size < chunkStep) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf,\n length: 1,\n index: 0,\n session\n }, target, customType));\n } else {\n const chunkSize = chunkStep * 1024 / Uint8Array.BYTES_PER_ELEMENT;\n const len = Math.ceil(size / chunkStep);\n let index = 0;\n while (index < len) {\n this.cachedMessages.push(ChunkedUpdateMessage.fromObject({\n buf: buf.slice(index * chunkSize, (index + 1) * chunkSize),\n length: len,\n index: index,\n session\n }, target, customType));\n index += 1;\n }\n }\n }\n async userList() {\n const output = new Set();\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false\n });\n let nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n while (nextPage) {\n const result = await this.rtmClient.presence.whoNow(this.roomChannel(), 'MESSAGE', {\n includedState: false,\n page: nextPage\n });\n nextPage = result.nextPage;\n result.occupants.forEach(userInfo => {\n const {\n userId\n } = userInfo;\n output.add(userId);\n });\n }\n return output;\n }\n async fetchHistoryMessage(begin, end, channel) {\n let start = begin;\n let continueFetch = true;\n const output = [];\n while (continueFetch) {\n const response = await this.rtmClient.history.getMessages(channel, 'MESSAGE', {\n start: start,\n end: end\n });\n if (response.newStart !== 0) {\n start = response.newStart;\n } else {\n continueFetch = false;\n }\n const chunkedMessages = new Map();\n for (const msg of response.messageList) {\n const chunked = ChunkedUpdateMessage.fromBuffer(msg.message, msg.publisher, msg.customType);\n if (chunked.length === 1) {\n output.push({\n buf: chunked.buf,\n publisher: msg.publisher,\n customType: msg.customType,\n isRoomChannel: channel === this.roomChannel()\n });\n } else {\n const chunks = chunkedMessages.get(chunked.session) || [];\n chunks.push(chunked);\n if (chunks.length === chunked.length) {\n const buffer = chunks.sort((a, b) => a.index - b.index).reduce((result, next) => {\n const buf = next.buf;\n const output = new Uint8Array(result.length + buf.length);\n output.set(result, 0);\n output.set(buf, result.length);\n return output;\n }, new Uint8Array());\n output.push({\n buf: buffer,\n publisher: msg.publisher,\n customType: msg.customType,\n isRoomChannel: channel === this.roomChannel()\n });\n chunkedMessages.delete(chunked.session);\n } else {\n chunkedMessages.set(chunked.session, chunks);\n }\n }\n }\n }\n return output;\n }\n async historyMessage(begin, end) {\n try {\n const roomMessages = await this.fetchHistoryMessage(end, begin, this.roomChannel());\n const userMessages = await this.fetchHistoryMessage(end, begin, this.userChannel(this.userId));\n return roomMessages.concat(userMessages);\n } catch (error) {\n this.emit('error', 'rtm historyMessage not support: ' + error);\n console.warn('rtm historyMessage not support: ' + error);\n return null;\n }\n }\n async setUserWritable(writable, userId) {\n // \u7F13\u5B58\u7684\u4F5C\u7528\u662F\u52A0\u5165\u9891\u9053\u4E4B\u540E\u624D\u80FD\u8C03\u7528 setChannelMetadata\uFF0C\u6240\u4EE5\u7F13\u5B58\u5E94\u8BE5\u5728\u52A0\u5165\u9891\u9053\u6210\u529F\u540E\u5220\u9664\n const targetUserId = userId || this.userId;\n if (!this.isInitialized) {\n this.cachedWritable.set(targetUserId, writable);\n return;\n }\n await this.rtmClient.storage.setChannelMetadata(this.writableChannel(), 'MESSAGE', [{\n key: targetUserId,\n value: writable ? 'true' : 'false'\n }]);\n }\n async getUserWritable(userId) {\n const targetUserId = userId || this.userId;\n try {\n const channelMeta = await this.rtmClient.storage.getChannelMetadata(this.writableChannel(), 'MESSAGE');\n const value = channelMeta.metadata[targetUserId]?.value;\n return value === 'true';\n } catch (error) {\n log('getUserWritable failed', {\n error: error.toString(),\n userId: targetUserId,\n rtm: '2.2'\n }, 'warn');\n return true;\n }\n }\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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QACR,KAAK;AAAA,MACP,GAAG,MAAM;AACT,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["_defineProperty", "_toPropertyKey", "_toPrimitive", "EventEmitter", "userId", "uuidv4", "result", "import_forge_room", "import_eventemitter3", "import_uuid", "_defineProperty", "_toPropertyKey", "_toPrimitive", "EventEmitter", "userId", "uuidv4", "result", "output"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/forge-rtm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/rtm-provider.js",
|
|
6
6
|
"module": "dist/rtm-provider.esm.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"js-base64": "^3.7.7",
|
|
12
12
|
"eventemitter3": "^5.0.1",
|
|
13
13
|
"uuid": "^9.0.1",
|
|
14
|
-
"@netless/forge-room": "1.0.
|
|
14
|
+
"@netless/forge-room": "1.1.0-beta.1"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [],
|
|
17
17
|
"author": "",
|