Skip to content

Commit f33de6a

Browse files
committed
chore: create muxer before async
1 parent 5db7b34 commit f33de6a

File tree

1 file changed

+7
-7
lines changed
  • packages/transport-webrtc/src/private-to-public/utils

1 file changed

+7
-7
lines changed

packages/transport-webrtc/src/private-to-public/utils/connect.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ const CONNECTION_STATE_CHANGE_EVENT = isFirefox ? 'iceconnectionstatechange' : '
4040
export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: string, options: ClientOptions): Promise<Connection>
4141
export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: string, options: ServerOptions): Promise<void>
4242
export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: string, options: ConnectOptions): Promise<any> {
43+
const muxerFactory = new DataChannelMuxerFactory({
44+
// @ts-expect-error https://github.com/murat-dogan/node-datachannel/pull/370
45+
peerConnection,
46+
metrics: options.events,
47+
dataChannelOptions: options.dataChannel
48+
})
49+
4350
// create data channel for running the noise handshake. Once the data
4451
// channel is opened, the listener will initiate the noise handshake. This
4552
// is used to confirm the identity of the peer.
@@ -149,13 +156,6 @@ export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: s
149156
// Track opened peer connection
150157
options.events?.increment({ peer_connection: true })
151158

152-
const muxerFactory = new DataChannelMuxerFactory({
153-
// @ts-expect-error https://github.com/murat-dogan/node-datachannel/pull/370
154-
peerConnection,
155-
metrics: options.events,
156-
dataChannelOptions: options.dataChannel
157-
})
158-
159159
if (options.role === 'client') {
160160
// For outbound connections, the remote is expected to start the noise
161161
// handshake. Therefore, we need to secure an inbound noise connection

0 commit comments

Comments
 (0)