Skip to content

Commit a39109f

Browse files
committed
argument order
1 parent 392d7d2 commit a39109f

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

examples/demo/demo.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
ConnectionState,
1515
DisconnectReason,
1616
ExternalE2EEKeyProvider,
17-
LocalAudioTrack,
1817
LogLevel,
1918
MediaDeviceFailure,
2019
Participant,
@@ -247,7 +246,7 @@ const appActions = {
247246
);
248247
});
249248

250-
room.setTextStreamHandler(async (reader, participant) => {
249+
room.registerTextStreamHandler('chat', async (reader, participant) => {
251250
const info = reader.info;
252251
if (info.size) {
253252
handleChatMessage(
@@ -272,9 +271,9 @@ const appActions = {
272271
appendLog('text stream finished');
273272
}
274273
console.log('final info including close extensions', reader.info);
275-
}, 'chat');
274+
});
276275

277-
room.setByteStreamHandler(async (reader, participant) => {
276+
room.registerByteStreamHandler('files', async (reader, participant) => {
278277
const info = reader.info;
279278

280279
appendLog(`started to receive a file called "${info.name}" from ${participant?.identity}`);
@@ -289,7 +288,7 @@ const appActions = {
289288
linkEl.innerText = info.name;
290289
linkEl.setAttribute('download', info.name);
291290
document.body.append(linkEl);
292-
}, 'welcome');
291+
});
293292

294293
try {
295294
// read and set current key from input

src/room/Room.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,25 +278,25 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
278278
}
279279
}
280280

281-
registerTextStreamHandler(callback: TextStreamHandler, topic: string = '') {
281+
registerTextStreamHandler(topic: string, callback: TextStreamHandler) {
282282
if (this.textStreamHandlers.has(topic)) {
283283
throw new TypeError(`A text stream handler for topic "${topic}" has already been set.`);
284284
}
285285
this.textStreamHandlers.set(topic, callback);
286286
}
287287

288-
unregisterTextStreamHandler(topic: string = '') {
288+
unregisterTextStreamHandler(topic: string) {
289289
this.textStreamHandlers.delete(topic);
290290
}
291291

292-
registerByteStreamHandler(callback: ByteStreamHandler, topic: string = '') {
292+
registerByteStreamHandler(topic: string, callback: ByteStreamHandler) {
293293
if (this.byteStreamHandlers.has(topic)) {
294294
throw new TypeError(`A byte stream handler for topic "${topic}" has already been set.`);
295295
}
296296
this.byteStreamHandlers.set(topic, callback);
297297
}
298298

299-
unregisterByteStreamHandler(topic: string = '') {
299+
unregisterByteStreamHandler(topic: string) {
300300
this.byteStreamHandlers.delete(topic);
301301
}
302302

0 commit comments

Comments
 (0)