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.mjs CHANGED
@@ -4693,6 +4693,16 @@ function requireRTCPeerConnection () {
4693
4693
  * @private
4694
4694
  */
4695
4695
  _openDataChannels() {
4696
+ // Check if network transport has active connections
4697
+ const hasConnections = this._networkTransport &&
4698
+ this._networkTransport.tcpTransport &&
4699
+ this._networkTransport.tcpTransport.connections.size > 0;
4700
+
4701
+ if (!hasConnections) {
4702
+ // Network not ready yet, channels will be opened when connection establishes
4703
+ return;
4704
+ }
4705
+
4696
4706
  for (const channel of this._dataChannels.values()) {
4697
4707
  if (channel.readyState === 'connecting') {
4698
4708
  this._connectChannelToNetwork(channel);
@@ -5082,15 +5092,8 @@ function requireRTCPeerConnection () {
5082
5092
  // Open data channels when connection is established
5083
5093
  this._sctpTransport.once('statechange', () => {
5084
5094
  if (this._sctpTransport.state === 'connected') {
5085
- for (const channel of this._dataChannels.values()) {
5086
- if (channel.readyState === 'connecting') {
5087
- // Hook up channel to network transport first
5088
- this._connectChannelToNetwork(channel);
5089
-
5090
- // Then set state to open (emits 'open' event)
5091
- channel._setStateToOpen();
5092
- }
5093
- }
5095
+ // Wait for network to be ready before opening channels
5096
+ this._openDataChannels();
5094
5097
  }
5095
5098
  });
5096
5099
  }
@@ -5317,7 +5320,7 @@ function requireRTCPeerConnection () {
5317
5320
  return RTCPeerConnection_1;
5318
5321
  }
5319
5322
 
5320
- var version = "1.0.17";
5323
+ var version = "1.0.18";
5321
5324
  var require$$10 = {
5322
5325
  version: version};
5323
5326