@@ -60,7 +60,7 @@ const sysInfo = Utils.sysInfo();
6060class P2PPeerConnectionChannel extends EventDispatcher {
6161 // |signaling| is an object has a method |sendSignalingMessage|.
6262 /* eslint-disable-next-line require-jsdoc */
63- constructor ( config , localId , remoteId , signaling ) {
63+ constructor ( config , localId , remoteId , signaling , isInitializer ) {
6464 super ( ) ;
6565 this . _config = config ;
6666 this . _localId = localId ;
@@ -93,6 +93,10 @@ class P2PPeerConnectionChannel extends EventDispatcher {
9393 this . _infoSent = false ;
9494 this . _disposed = false ;
9595 this . _createPeerConnection ( ) ;
96+ if ( isInitializer ) {
97+ this . _sendSignalingMessage ( SignalingType . CLOSED ) ;
98+ }
99+ this . _sendSignalingMessage ( SignalingType . UA , sysInfo ) ;
96100 }
97101
98102 /**
@@ -114,9 +118,7 @@ class P2PPeerConnectionChannel extends EventDispatcher {
114118 ErrorModule . errors . P2P_CLIENT_INVALID_STATE ,
115119 'All tracks are ended.' ) ) ;
116120 }
117- return Promise . all ( [ this . _sendClosedMsgIfNecessary ( ) ,
118- this . _sendSysInfoIfNecessary ( ) ,
119- this . _sendStreamInfo ( stream ) ] ) . then ( ( ) => {
121+ return this . _sendStreamInfo ( stream ) . then ( ( ) => {
120122 return new Promise ( ( resolve , reject ) => {
121123 // Replace |addStream| with PeerConnection.addTrack when all browsers are ready.
122124 for ( const track of stream . mediaStream . getTracks ( ) ) {
@@ -159,14 +161,6 @@ class P2PPeerConnectionChannel extends EventDispatcher {
159161 this . _createDataChannel ( DataChannelLabel . MESSAGE ) ;
160162 }
161163
162- this . _sendClosedMsgIfNecessary ( ) . catch ( ( err ) => {
163- Logger . debug ( 'Failed to send closed message.' + err . message ) ;
164- } ) ;
165-
166- this . _sendSysInfoIfNecessary ( ) . catch ( ( err ) => {
167- Logger . debug ( 'Failed to send sysInfo.' + err . message ) ;
168- } ) ;
169-
170164 const dc = this . _dataChannels . get ( DataChannelLabel . MESSAGE ) ;
171165 if ( dc . readyState === 'open' ) {
172166 this . _dataChannels . get ( DataChannelLabel . MESSAGE ) . send (
@@ -242,7 +236,6 @@ class P2PPeerConnectionChannel extends EventDispatcher {
242236 switch ( message . type ) {
243237 case SignalingType . UA :
244238 this . _handleRemoteCapability ( message . data ) ;
245- this . _sendSysInfoIfNecessary ( ) ;
246239 break ;
247240 case SignalingType . TRACK_SOURCES :
248241 this . _trackSourcesHandler ( message . data ) ;
@@ -803,23 +796,6 @@ class P2PPeerConnectionChannel extends EventDispatcher {
803796 ] ) ;
804797 }
805798
806-
807- _sendSysInfoIfNecessary ( ) {
808- if ( this . _infoSent ) {
809- return Promise . resolve ( ) ;
810- }
811- this . _infoSent = true ;
812- return this . _sendSignalingMessage ( SignalingType . UA , sysInfo ) ;
813- }
814-
815- _sendClosedMsgIfNecessary ( ) {
816- if ( this . _pc . remoteDescription === null ||
817- this . _pc . remoteDescription . sdp === '' ) {
818- return this . _sendSignalingMessage ( SignalingType . CLOSED ) ;
819- }
820- return Promise . resolve ( ) ;
821- }
822-
823799 _handleRemoteCapability ( ua ) {
824800 if ( ua . sdk && ua . sdk && ua . sdk . type === 'JavaScript' && ua . runtime &&
825801 ua . runtime . name === 'Firefox' ) {
0 commit comments