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

Commit 110618e

Browse files
committed
Send publication ID after creating QUIC stream.
1 parent 0ab3437 commit 110618e

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/sdk/conference/quicchannel.js

Lines changed: 19 additions & 5 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 */
6+
/* global Promise, Map, QuicTransport, Uint8Array */
77

88
'use strict';
99

@@ -24,7 +24,7 @@ export class QuicChannel extends EventDispatcher {
2424
super();
2525
this._signaling = signaling;
2626
this._ended = false;
27-
this._quicStreams = new Map(); // Key is publication or subscription ID.
27+
this._quicStreams = new Map(); // Key is publication or subscription ID.
2828
this._quicTransport = new QuicTransport(url);
2929
}
3030

@@ -57,9 +57,23 @@ export class QuicChannel extends EventDispatcher {
5757
async createSendStream(sessionId) {
5858
Logger.info('Create stream.');
5959
await this._quicTransport.ready;
60-
const quicStream=this._quicTransport.createSendStream();
61-
const publicationId=await this._initializePublication();
62-
// Send publication ID to quicStream.
60+
// TODO: Creating quicStream and initializing publication concurrently.
61+
const quicStream = await this._quicTransport.createSendStream();
62+
const publicationId = await this._initializePublication();
63+
const writer= quicStream.writable.getWriter();
64+
await writer.ready;
65+
writer.write(this.uuidToUint8Array(publicationId));
66+
}
67+
68+
uuidToUint8Array(uuidString) {
69+
if (uuidString.length != 32) {
70+
throw new TypeError('Incorrect UUID.');
71+
}
72+
const uuidArray = new Uint8Array(16);
73+
for (let i = 0; i < 16; i++) {
74+
uuidArray[i] = parseInt(uuidString.substring(i * 2, i * 2 + 2), 16);
75+
}
76+
return uuidArray;
6377
}
6478

6579
/**

0 commit comments

Comments
 (0)