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

Commit 52df045

Browse files
committed
Add description for QUIC sample.
1 parent 4ac8607 commit 52df045

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

src/samples/conference/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
How to run conference sample
2-
============================
1+
Conference sample
2+
----
3+
4+
## How to run conference sample
35

46
1. Run `npm install`.
57
2. Edit `samplertcservice.js`. Find `icsREST.API.init`, replace service ID, service key and REST server URL with the correct values.
68
3. Copy your SSL server certificate to cert/certificate.pfx.
79
4. Run `initcert.js` to generate a keystore file which contains encrypted SSL server's passphase.
810
5. Run `node samplertcservice.js` to start conference sample. By default, it listens on port 3001(insecure) and 3004(secure).
9-
6. Open a browser and navigate to http://\<hostname\>:3001/ or https://\<hostname\>:3004/.
11+
6. Open a browser and navigate to http://hostname:3001/ or https://hostname:3004/.
12+
13+
## QUIC
14+
15+
`public\scripts\index.js` was modified to create QUIC connections between client and server. After navigating to https://hostname:3004/?publish=false, the page automatically creates a QuicStream for publishing. It also listens to `stream-added` message and creates new QuicStreams for subscribing. It doesn't subscribe streams published before joining. `window.bidirectionalStream` is the last QuicStream it created. You may write or read data in console by accessing `window.bidirectionalStream`. Please try to modify index.js if you want to try other QUIC features.

src/samples/conference/public/scripts/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const runSocketIOSample = function() {
145145
myId = resp.self.id;
146146
myRoom = resp.id;
147147
conference.createDataStream().then(stream=>{
148-
bidirectionalStream=stream;
148+
window.bidirectionalStream=stream;
149149
});
150150
if(mediaUrl){
151151
startStreamingIn(myRoom, mediaUrl);

src/sdk/conference/datachannel.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,23 @@ export class ConferenceDataChannel extends EventDispatcher {
116116
}
117117
}
118118

119+
_readAndPrint(){
120+
this._quicStreams[0].waitForReadable(5).then(()=>{
121+
let data = new Uint8Array(this._quicStreams[0].readBufferedAmount);
122+
this._quicStreams[0].readInto(data);
123+
Logger.info('Read data: ' + data);
124+
this._readAndPrint();
125+
});
126+
}
127+
119128
_onquicstatechange(event) {
120129
Logger.info('on QUIC state change: ' + this._quicTransport.state);
121130
if (this._quicTransport.state === 'connected') {
122131
if (this._quicStreams.length === 0) {
123132
this._quicStreams.push(this._quicTransport.createStream());
124133
this._quicStreams[0].write({data: new Uint8Array([42])});
125134
// 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-
});
135+
this._readAndPrint();
131136
if (this._createStreamPromise) {
132137
this._createStreamPromise.resolve(this._quicStreams[0]);
133138
}

0 commit comments

Comments
 (0)