Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 4ac8607

Browse files
committed
Dispatch messages to incoming data channels.
1 parent 7c7cd4c commit 4ac8607

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/sdk/conference/client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ export const ConferenceClient = function(config, signalingImpl) {
130130
channels.get(data.id).onMessage(notification, data);
131131
} else if (dataChannelId === data.id) {
132132
dataChannel.onMessage(notification, data);
133+
} else if (incomingDataChannels.has(data.id)){
134+
incomingDataChannels.get(data.id).onMessage(notification, data);
133135
} else {
134136
Logger.warning('Cannot find a channel for incoming data.');
135137
}

src/sdk/conference/datachannel.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export class ConferenceDataChannel extends EventDispatcher {
6868
* @private
6969
*/
7070
createStream() {
71+
Logger.info('Create stream.');
7172
if (this._quicTransport && this._quicTransport.state == 'connected') {
72-
const stream = this._quicTransport.createStream()
7373
this._quicStreams.push(stream);
7474
return Promise.resolve(stream);
7575
}
@@ -121,6 +121,13 @@ export class ConferenceDataChannel extends EventDispatcher {
121121
if (this._quicTransport.state === 'connected') {
122122
if (this._quicStreams.length === 0) {
123123
this._quicStreams.push(this._quicTransport.createStream());
124+
this._quicStreams[0].write({data: new Uint8Array([42])});
125+
// This is an experienment of receiving data.
126+
this._quicStreams[0].waitForReadable(1).then(() => {
127+
let data = new Uint8Array(1);
128+
this._quicStreams[0].readInto(data);
129+
Logger.info('Read data: ' + data);
130+
});
124131
if (this._createStreamPromise) {
125132
this._createStreamPromise.resolve(this._quicStreams[0]);
126133
}

0 commit comments

Comments
 (0)