我正在使用 JsSIP 连接到 FreeSwitch,然后连接到 PSTN。我希望在 From 标头中传递 callerID。我的代码设置有点像这样:
var TheCallerIDTest = '+33...number in E164 format';
var TheSipClient = new JsSIP.UA({....}); //works fine
var TheHandlers = {
'sending': function (e) {
var TheSipURI = new JsSIP.URI('sip', TheCallerIDTest, 'MyFreeswitchServerUrl', 5060, null, null);
var TheHeader = new JsSIP.NameAddrHeader(TheSipURI, '', null);
//displays the correct From header just fine
console.log(TheHeader);
//here's where I want to modify the INVITE request
e.from = TheHeader;
},
}
var TheCallOptions = {
'eventHandlers': TheHandlers,
'mediaConstraints': { 'audio': true, 'video': false }
};
function TestCall() {
TheSipClient.start();
TheSipClient.call("+33...E164 number", TheCallOptions);
}
查看文档https://jssip.net/documentation/3.3.x/api/session/#event_sending,我希望在请求JsSIP.NameAddrHeader
的“来自”标头中添加一个JsSIP.OutgoingRequest INVITE
。控制台输出记录了我要添加的正确 From 标头。
但是,当我查看JsSIP:RTCSession emit "sending" [request:InitialOutgoingInviteRequest
控制台日志时,它没有显示我要添加的标头,并且在服务器上收到的 From 标头不是我要发送的标头。
我需要对代码进行哪些更改才能使其正常工作?