@@ -907,35 +907,38 @@ Duration=${payload.duration} `
907
907
...( req . has ( 'X-Retain-Call-Sid' ) && { 'X-Retain-Call-Sid' : req . get ( 'X-Retain-Call-Sid' ) } ) ,
908
908
...( req . has ( 'X-Account-Sid' ) && { 'X-Account-Sid' : req . get ( 'X-Account-Sid' ) } )
909
909
} ;
910
- const dlg = await this . srf . createUAC ( referTo . uri , { localSdp : dlg . local . sdp , headers} ) ;
911
- this . uas = dlg ;
912
- this . uas . other = this . uac ;
913
- this . uac . other = this . uas ;
914
- this . uas . on ( 'modify' , this . _onReinvite . bind ( this , this . uas ) ) ;
915
- this . uas . on ( 'refer' , this . _onFeatureServerTransfer . bind ( this , this . uas ) ) ;
916
- this . uas . on ( 'destroy' , ( ) => {
910
+
911
+ const uac = await this . srf . createUAC ( referTo . uri , { localSdp : dlg . local . sdp , headers} ) ;
912
+ this . uas = uac ;
913
+ uac . type = 'uas' ;
914
+ uac . other = this . uac ;
915
+ this . uac . other = uac ;
916
+ uac . on ( 'info' , this . _onInfo . bind ( this , uac ) ) ;
917
+ uac . on ( 'modify' , this . _onReinvite . bind ( this , uac ) ) ;
918
+ uac . on ( 'refer' , this . _onFeatureServerTransfer . bind ( this , uac ) ) ;
919
+ uac . on ( 'destroy' , ( ) => {
917
920
this . logger . info ( 'call ended with normal termination' ) ;
918
921
this . rtpEngineResource . destroy ( ) ;
919
922
this . activeCallIds . delete ( this . req . get ( 'Call-ID' ) ) ;
920
923
if ( this . activeCallIds . size === 0 ) this . idleEmitter . emit ( 'idle' ) ;
921
- this . uas . other . destroy ( ) ;
924
+ uac . other . destroy ( ) ;
922
925
this . srf . endSession ( this . req ) ;
923
926
} ) ;
924
927
925
- // modify rtpengine to stream to new feature server
926
- let response = await this . offer ( Object . assign ( this . rtpEngineOpts . offer , { sdp : this . uas . remote . sdp } ) ) ;
927
- if ( 'ok' !== response . result ) {
928
- throw new Error ( `_onReinvite: rtpengine failed: offer: ${ JSON . stringify ( response ) } ` ) ;
929
- }
930
- const sdp = await this . uas . other . modify ( response . sdp ) ;
931
- const opts = Object . assign ( { sdp, 'to-tag' : res . getParsedHeader ( 'To' ) . params . tag } ,
932
- this . rtpEngineOpts . answer ) ;
933
- response = await this . answer ( opts ) ;
928
+ const opts = {
929
+ ...this . rtpEngineOpts . common ,
930
+ 'from-tag' : this . rtpEngineOpts . uas . tag ,
931
+ sdp : uac . remote . sdp ,
932
+ flags : [ 'port latching' ]
933
+ } ;
934
+ const response = await this . offer ( opts ) ;
934
935
if ( 'ok' !== response . result ) {
935
- throw new Error ( `_onReinvite : rtpengine failed: ${ JSON . stringify ( response ) } ` ) ;
936
+ throw new Error ( `_onFeatureServerTransfer : rtpengine offer failed: ${ JSON . stringify ( response ) } ` ) ;
936
937
}
938
+ dlg . destroy ( ) . catch ( ( ) => { } ) ;
937
939
this . logger . info ( 'successfully moved call to new feature server' ) ;
938
940
} catch ( err ) {
941
+ res . send ( 488 ) ;
939
942
this . logger . error ( err , 'Error handling refer from feature server' ) ;
940
943
}
941
944
}
0 commit comments