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

Commit 0635a1e

Browse files
authored
Use WebTransport instead of QuicTransport. (#457)
* Use WebTransport instead of QuicTransport. QuicTransport was merged to WebTransport. This change updates some calls to comply with the latest spec. This change also resolves join after authentication is passed for WebTransport. * Fix an eslint error.
1 parent 33f9552 commit 0635a1e

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

docs/design/webtransport.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Following APIs will be changed to support QuicTransport.
1818

1919
JavaScript SDK creates a QuicTransport with a QUIC agent when QUIC agent is enabled at server side, and WebTransport is supported at client side. When app publishes or subscribes a data stream, a new QuicStream is created.
2020

21+
## Limitations
22+
23+
WebTransport only supported in Chrome since 87. It's not enabled by default. To enable it, you need to [register the origin trail](https://web.dev/webtransport/#register-for-ot) or start Chrome with flag `--enable-experimental-web-platform-features`.
24+
2125
## Examples
2226

2327
### Send data to a conference

docs/jsdoc/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"outputSourcePath": false,
2020
"systemName": "Intel® Collaboration Suite for WebRTC version 5.0",
2121
"footer": "",
22-
"copyright": "Copyright © 2020 Intel Corporation. All Rights Reserved.",
22+
"copyright": "Copyright © 2021 Intel Corporation. All Rights Reserved.",
2323
"navType": "vertical",
2424
"theme": "cosmo",
2525
"linenums": true,

src/sdk/conference/client.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,21 @@ export const ConferenceClient = function(config, signalingImpl) {
416416
}
417417
}
418418
}
419-
if (typeof QuicTransport === 'function' && token.webTransportUrl) {
419+
if (typeof WebTransport === 'function' && token.webTransportUrl) {
420420
quicTransportChannel = new QuicConnection(
421421
token.webTransportUrl, resp.webTransportToken,
422422
createSignalingForChannel(), config.webTransportConfiguration);
423423
}
424-
resolve(new ConferenceInfo(resp.room.id, Array.from(participants
425-
.values()), Array.from(remoteStreams.values()), me));
424+
const conferenceInfo = new ConferenceInfo(
425+
resp.room.id, Array.from(participants.values()),
426+
Array.from(remoteStreams.values()), me);
427+
if (quicTransportChannel) {
428+
quicTransportChannel.init().then(() => {
429+
resolve(conferenceInfo);
430+
});
431+
} else {
432+
resolve(conferenceInfo);
433+
}
426434
}, (e) => {
427435
signalingState = SignalingState.READY;
428436
reject(new ConferenceError(e));

src/sdk/conference/quicconnection.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
/* eslint-disable require-jsdoc */
6-
/* global Promise, Map, QuicTransport, Uint8Array, Uint32Array, TextEncoder */
6+
/* global Promise, Map, WebTransport, Uint8Array, Uint32Array, TextEncoder */
77

88
'use strict';
99

@@ -25,15 +25,15 @@ export class QuicConnection extends EventDispatcher {
2525
// value of `ConferenceClient.join`.
2626
constructor(url, tokenString, signaling, webTransportOptions) {
2727
super();
28+
this._tokenString = tokenString;
2829
this._token = JSON.parse(Base64.decodeBase64(tokenString));
2930
this._signaling = signaling;
3031
this._ended = false;
3132
this._quicStreams = new Map(); // Key is publication or subscription ID.
32-
this._quicTransport = new QuicTransport(url, webTransportOptions);
33+
this._quicTransport = new WebTransport(url, webTransportOptions);
3334
this._subscribePromises = new Map(); // Key is subscription ID.
3435
this._transportId = this._token.transportId;
35-
this._init();
36-
this._authenticate(tokenString);
36+
this._initReceiveStreamReader();
3737
}
3838

3939
/**
@@ -63,9 +63,13 @@ export class QuicConnection extends EventDispatcher {
6363
}
6464
}
6565

66-
async _init() {
66+
async init() {
67+
await this._authenticate(this._tokenString);
68+
}
69+
70+
async _initReceiveStreamReader() {
6771
const receiveStreamReader =
68-
this._quicTransport.receiveStreams().getReader();
72+
this._quicTransport.incomingBidirectionalStreams.getReader();
6973
Logger.info('Reader: ' + receiveStreamReader);
7074
let receivingDone = false;
7175
while (!receivingDone) {
@@ -127,7 +131,7 @@ export class QuicConnection extends EventDispatcher {
127131

128132
async createSendStream() {
129133
await this._quicTransport.ready;
130-
const quicStream = await this._quicTransport.createSendStream();
134+
const quicStream = await this._quicTransport.createBidirectionalStream();
131135
return quicStream;
132136
}
133137

0 commit comments

Comments
 (0)