Skip to content

Commit 23134fd

Browse files
authored
Merge pull request #369 from mertushka/fix-unordered-opts
fix: map RTCDataChannelInit to native DataChannelInitConfig
2 parents d83ba00 + e37eecb commit 23134fd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/polyfill/RTCPeerConnection.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import { SelectedCandidateInfo } from '../lib/types';
2+
import { DataChannelInitConfig, SelectedCandidateInfo } from '../lib/types';
33
import { PeerConnection } from '../lib/index';
44
import RTCSessionDescription from './RTCSessionDescription';
55
import RTCDataChannel from './RTCDataChannel';
@@ -362,7 +362,13 @@ export default class RTCPeerConnection extends EventTarget implements globalThis
362362
}
363363

364364
createDataChannel(label: string, opts: globalThis.RTCDataChannelInit = {}): RTCDataChannel {
365-
const channel = this.#peerConnection.createDataChannel(label, opts);
365+
const nativeOpts: DataChannelInitConfig = {
366+
...opts,
367+
// libdatachannel uses "unordered", opposite of RTCDataChannelInit.ordered
368+
unordered: opts.ordered === false ? true : false,
369+
};
370+
371+
const channel = this.#peerConnection.createDataChannel(label, nativeOpts);
366372
const dataChannel = new RTCDataChannel(channel, opts);
367373

368374
// ensure we can close all channels when shutting down

0 commit comments

Comments
 (0)