@@ -11,7 +11,7 @@ var wildcard = require('wildcard');
1111
1212var OPTIONAL_MONITOR_EVENTS = [
1313 'negotiate:request' , 'negotiate:renegotiate' , 'negotiate:abort' ,
14- 'negotiate:createOffer' , 'negotiate:createOffer:created' ,
14+ 'negotiate:createOffer' , 'negotiate:createOffer:created' ,
1515 'negotiate:createAnswer' , 'negotiate:createAnswer:created' ,
1616 'negotiate:setlocaldescription' ,
1717 'icecandidate:local' , 'icecandidate:remote' , 'icecandidate:gathered' , 'icecandidate:added' ,
@@ -23,7 +23,7 @@ var OPTIONAL_MONITOR_EVENTS = [
2323
2424 The `rtc-health` module helps make it easier to expose health information
2525 about your RTC connections. It hooks into the WebRTC Stats API, as well as the
26- underlying signaller and PeerConnection events to provide insight as to events,
26+ underlying signaller and PeerConnection events to provide insight as to events,
2727 and metrics about any peer connections initiated by the provided quickconnect instance.
2828
2929 ## Example Usage
@@ -60,16 +60,16 @@ module.exports = function(qc, opts) {
6060 if ( tc ) {
6161 timers [ data . id ] = setTimeout ( log . bind ( this , peerId , pc , data ) , emitter . pollInterval ) ;
6262 }
63-
63+
6464 var reporter = new Reporter ( {
65- source : qc . id ,
65+ source : qc . id ,
6666 about : data ,
6767 pc : pc ,
6868 reports : reports
6969 } ) ;
7070
7171 emitter . emit ( 'health:report' , reporter , pc ) ;
72- } ) ;
72+ } ) ;
7373 }
7474
7575 /**
@@ -102,7 +102,7 @@ module.exports = function(qc, opts) {
102102 **/
103103 qc . on ( 'peer:connect' , trackConnection ) ;
104104
105- qc . on ( 'peer:couple' , function ( peerId , pc , data , monitor ) {
105+ qc . on ( 'peer:couple' , function ( peerId , pc , data , monitor ) {
106106
107107 // Store that we are currently tracking the target peer
108108 var tc = connections [ data . id ] ;
@@ -112,8 +112,8 @@ module.exports = function(qc, opts) {
112112 monitor . on ( 'statechange' , function ( pc , state ) {
113113 var iceConnectionState = pc . iceConnectionState ;
114114 var newStatus = util . toStatus ( iceConnectionState ) ;
115- notify ( 'icestatus' , {
116- source : qc . id , about : data . id , tracker : tc
115+ notify ( 'icestatus' , {
116+ source : qc . id , about : data . id , tracker : tc
117117 } , iceConnectionState ) ;
118118 emitter . emit ( 'health:changed' , tc , iceConnectionState ) ;
119119
@@ -129,7 +129,7 @@ module.exports = function(qc, opts) {
129129 } ) ;
130130
131131 monitor . on ( 'closed' , function ( ) {
132-
132+
133133 tc . closed ( ) ;
134134
135135 // Stop the reporting for this peer connection
@@ -138,7 +138,7 @@ module.exports = function(qc, opts) {
138138
139139 // Emit a closure status update
140140 emitter . emit ( 'health:report' , new Reporter ( {
141- source : qc . id ,
141+ source : qc . id ,
142142 about : data ,
143143 status : 'closed' ,
144144 force : true
@@ -155,7 +155,7 @@ module.exports = function(qc, opts) {
155155
156156 if ( util . SIGNALLER_EVENTS . indexOf ( name ) >= 0 ) {
157157 return notify . apply (
158- notify ,
158+ notify ,
159159 [ name , { source : qc . id , about : 'signaller' } ] . concat ( evt . args )
160160 ) ;
161161 }
@@ -167,7 +167,7 @@ module.exports = function(qc, opts) {
167167 var shortName = matching . slice ( 2 ) . join ( '.' ) ;
168168 var tc = connections [ peerId ] ;
169169 return notify . apply (
170- notify ,
170+ notify ,
171171 [ shortName , { source : qc . id , about : peerId , tracker : tc } ] . concat ( evt . args )
172172 ) ;
173173 }
@@ -187,7 +187,12 @@ module.exports = function(qc, opts) {
187187 results . push ( connections [ target ] ) ;
188188 }
189189 return results ;
190- }
190+ } ;
191+
192+ // Get the tracked connection for the given target peer
193+ emitter . getConnection = function ( target ) {
194+ return connections && connections [ target ] ;
195+ } ;
191196
192197 return emitter ;
193198} ;
0 commit comments