@babblevoice/projectrtp 2.3.6 → 2.3.8

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/index.js CHANGED
@@ -468,6 +468,10 @@ class projectrtp {
468
468
  else chan.id = uuidv4()
469
469
 
470
470
  chan.uuid = uuidv4()
471
+
472
+ /* ensure we are identicle to the node version of this object */
473
+ chan.openchannel = this.openchannel.bind( this )
474
+
471
475
  return chan
472
476
  }
473
477
  }
package/lib/node.js CHANGED
@@ -78,7 +78,8 @@ class rtpnode {
78
78
  const con = {
79
79
  connectionid: uuidv4(),
80
80
  connection,
81
- "connectionlength": 0
81
+ "connectionlength": 0,
82
+ "mode": "connect"
82
83
  }
83
84
  this.connections[ con.connectionid ] = con
84
85
  this.connection.on( "data", this._onsocketdata.bind( this, con ) )
@@ -97,7 +98,8 @@ class rtpnode {
97
98
  const con = {
98
99
  connectionid: uuidv4(),
99
100
  connection,
100
- "connectionlength": 0
101
+ "connectionlength": 0,
102
+ "mode": "listen"
101
103
  }
102
104
  this.connections[ con.connectionid ] = con
103
105
  connection.setKeepAlive( true )
@@ -295,7 +297,7 @@ class rtpnode {
295
297
  con.connectionlength -= 1
296
298
  channels.delete( chan.uuid )
297
299
 
298
- if( 0 == con.connectionlength ) {
300
+ if( 0 == con.connectionlength && "listen" == con.mode ) {
299
301
  this.connections.delete( con.instance )
300
302
  con.connection.destroy()
301
303
  }
package/lib/server.js CHANGED
@@ -612,10 +612,6 @@ class channel {
612
612
  if( 0 === this.channels.length && this.connection.sock ) this.connection.sock.destroy()
613
613
  }
614
614
 
615
- if( this.connection && this.connection.sock && !this.channels ) {
616
- this.connection.sock.destroy()
617
- delete this.connection.sock
618
- }
619
615
 
620
616
  channels.delete( this.id )
621
617
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/projectrtp",
3
- "version": "2.3.6",
3
+ "version": "2.3.8",
4
4
  "description": "A scalable Node addon RTP server",
5
5
  "main": "index.js",
6
6
  "directories": {
package/stress/utils.js CHANGED
@@ -20,9 +20,18 @@ module.exports.logclosechannel = ( message, d, mstimeout ) => {
20
20
  channelcount--
21
21
  totalcount++
22
22
  module.exports.log( message )
23
- module.exports.log( ` Expected number of packets: ${Math.round(mstimeout / 20)}, Received: ${d.stats.in["count"]},` +
24
- ` Score: ${(d.stats.in["count"] / mstimeout * 20).toFixed(2)}` )
25
- module.exports.log( `Channel closed - current count now ${channelcount} total channels this session ${totalcount}` )
23
+
24
+ const score = ( d.stats.in["count"] / mstimeout * 20 ).toFixed( 2 )
25
+ let scoremsg = ` Score: ${ score }`
26
+
27
+ // Colour based on score: red, yellow, green
28
+ if( 0.25 >= score ) scoremsg = "\x1B[31m" + scoremsg
29
+ else if( 0.7 >= score ) scoremsg = "\x1B[33m" + scoremsg
30
+ else scoremsg = "\x1B[32m" + scoremsg
31
+ scoremsg += "\x1B[37m"
32
+
33
+ module.exports.log( `Expected number of packets: ${ Math.round( mstimeout / 20 ) }, Received: ${ d.stats.in[ "count" ] },` + scoremsg )
34
+ module.exports.log( `Channel closed - current count now ${ channelcount } total channels this session ${ totalcount }` )
26
35
  }
27
36
 
28
37
  module.exports.totalchannelcount = () => {
@@ -673,4 +673,21 @@ describe( "rtpproxy server", function() {
673
673
 
674
674
 
675
675
  } )
676
+ it( "Ensure connection stays open with 0 channel in listen mode", async () => {
677
+
678
+ const ourport = getnextport()
679
+ prtp.server.clearnodes()
680
+ const p = await prtp.proxy.listen( undefined, "127.0.0.1", ourport )
681
+ const ournode = await prtp.node.connect( ourport, "127.0.0.1" )
682
+
683
+
684
+ const chnl = await prtp.openchannel()
685
+ await new Promise( ( resolve ) => { setTimeout( () => resolve(), 100 ) } )
686
+ await chnl.close()
687
+ const chnl2 = await prtp.openchannel()
688
+ await chnl2.close()
689
+ await new Promise( ( resolve ) => { setTimeout( () => resolve(), 100 ) } )
690
+ ournode.destroy()
691
+ p.destroy()
692
+ } )
676
693
  } )