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

Commit 95b37a8

Browse files
committed
Update doc for WebTransport.
- Add new API changes. - Add examples.
1 parent ea2f536 commit 95b37a8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/design/webtransport.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,39 @@ Following APIs will be changed to support QuicTransport.
1010

1111
- `LocalStream` can be constructed with a `WritableStream`.
1212
- `RemoteStream` can be constructed with a `ReadableStream`.
13+
- `ConferenceClient` has new method `createSendStream` which returns a `LocalStream` with a unidirectional stream in it.
14+
- `StreamSourceInfo` has a new bool property `data`.
15+
1316

1417
## Internal Changes
1518

1619
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.
20+
21+
## Examples
22+
23+
### Send data to a conference
24+
25+
```
26+
const sendStream = conferenceClient.createSendStream();
27+
const publication = await conferenceClient.publish(sendStream);
28+
sendStream.stream.write(somethingToWrite);
29+
```
30+
31+
### Receive data from a conference
32+
33+
```
34+
conferenceClient.addEventListener('streamadded', async (event) => {
35+
if (event.stream.source.data) { // Data stream.
36+
const subscription = await conference.subscribe(event.stream);
37+
const reader = subscription.stream.readable.getReader();
38+
while (true) {
39+
const {value, done} = await reader.read();
40+
if (done) {
41+
// Stream ends.
42+
break;
43+
}
44+
ProcessData(value);
45+
}
46+
}
47+
});
48+
```

0 commit comments

Comments
 (0)