@@ -40,6 +40,13 @@ const CONNECTION_STATE_CHANGE_EVENT = isFirefox ? 'iceconnectionstatechange' : '
4040export async function connect ( peerConnection : DirectRTCPeerConnection , ufrag : string , options : ClientOptions ) : Promise < Connection >
4141export async function connect ( peerConnection : DirectRTCPeerConnection , ufrag : string , options : ServerOptions ) : Promise < void >
4242export 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