node-rtc-connection 1.0.17 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4695,6 +4695,16 @@ function requireRTCPeerConnection () {
4695
4695
  * @private
4696
4696
  */
4697
4697
  _openDataChannels() {
4698
+ // Check if network transport has active connections
4699
+ const hasConnections = this._networkTransport &&
4700
+ this._networkTransport.tcpTransport &&
4701
+ this._networkTransport.tcpTransport.connections.size > 0;
4702
+
4703
+ if (!hasConnections) {
4704
+ // Network not ready yet, channels will be opened when connection establishes
4705
+ return;
4706
+ }
4707
+
4698
4708
  for (const channel of this._dataChannels.values()) {
4699
4709
  if (channel.readyState === 'connecting') {
4700
4710
  this._connectChannelToNetwork(channel);
@@ -5084,15 +5094,8 @@ function requireRTCPeerConnection () {
5084
5094
  // Open data channels when connection is established
5085
5095
  this._sctpTransport.once('statechange', () => {
5086
5096
  if (this._sctpTransport.state === 'connected') {
5087
- for (const channel of this._dataChannels.values()) {
5088
- if (channel.readyState === 'connecting') {
5089
- // Hook up channel to network transport first
5090
- this._connectChannelToNetwork(channel);
5091
-
5092
- // Then set state to open (emits 'open' event)
5093
- channel._setStateToOpen();
5094
- }
5095
- }
5097
+ // Wait for network to be ready before opening channels
5098
+ this._openDataChannels();
5096
5099
  }
5097
5100
  });
5098
5101
  }
@@ -5319,7 +5322,7 @@ function requireRTCPeerConnection () {
5319
5322
  return RTCPeerConnection_1;
5320
5323
  }
5321
5324
 
5322
- var version = "1.0.17";
5325
+ var version = "1.0.18";
5323
5326
  var require$$10 = {
5324
5327
  version: version};
5325
5328