如何从响应中获得状态代码,如100和180,当我从控制台的响应中调用任何号码时。控制台输出我的呼叫响应如下所示,所以如何获得状态码,当我用nay号码呼叫时尝试和振铃。[1]: https://i.stack.imgur.com/YOTL8.png
也显示如下响应:
browser.js:183 JsSIP:WebSocketInterface received WebSocket message +13s
browser.js:183 JsSIP:Transport received text message:INVITE sip:rpj7...@127.0.0.1:55702;transport=WS SIP/2.0
Via: SIP/2.0/WS 127.0.0.1:8088;rport;branch=z9hG4bKPjacdc2b28-994d-49de-b3af-f3f7740afb93;alias
From: "F200" <sip:2...@XXXXX.com>;tag=95bffc6b-992b-48dd-83e1-23a2473e271e
To: <sip:rpj7...@127.0.0.1>
Contact: <sip:aste...@XXXXX.com:5060;transport=ws>
Call-ID: 3290aa94-d410-4bb5-ad10-b72e9a05ce04
CSeq: 3467 INVITE
Allow: OPTIONS, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, MESSAGE, REFER
Supported: 100rel, replaces, norefersub
P-Asserted-Identity: "F200" <sip:2...@XXXXX.com>
Max-Forwards: 70
User-Agent: Asterisk PBX 16.8.0-7.5.1.rl.101706.4465cf5
Content-Type: application/sdp
Content-Length: 935
v=0
...trimmed ordinary-looking incoming SDP
a=mid:audio-0
+13s
browser.js:183 JsSIP:Transport send() +1ms
browser.js:183 JsSIP:Transport sending message:SIP/2.0 100 Trying
... trimmed 100 trying body....
+0ms
browser.js:183 JsSIP:WebSocketInterface send() +6ms
browser.js:183 JsSIP:RTCSession new +3m
browser.js:183 JsSIP:RTCSession init_incoming() +1ms
browser.js:183 JsSIP:Dialog new UAS dialog created with status EARLY +3m
browser.js:183 JsSIP:RTCSession newRTCSession() +0ms
App.js:348 {id: 0.5232762505149955, remoteExt: "800", time: 1591730563324, state: "incoming", session: RTCSession}
browser.js:183 JsSIP:Transport send() +3ms
browser.js:183 JsSIP:Transport sending message:SIP/2.0 180 Ringing
... TRIMMED 180 Ringing body ....
Content-Length: 0
+0ms
browser.js:183 JsSIP:WebSocketInterface send() +3ms
browser.js:183 JsSIP:RTCSession session progress +2ms
browser.js:183 JsSIP:RTCSession emit "progress" +0ms
.... session.answer called here ...
browser.js:183 JsSIP:RTCSession answer() +501ms
browser.js:183 JsSIP:Dialog dialog 3290aa94-d410-4bb5-ad10-b72e9a05ce04sgb1kgc5mc95bffc6b-992b-48dd-83e1-23a2473e271e changed to CONFIRMED state +503ms
browser.js:183 JsSIP:RTCSession emit "peerconnection" +1ms
browser.js:183 JsSIP:WebSocketInterface received WebSocket message +2s
browser.js:183 JsSIP:Transport received text message:
+2s
common.js:114 JsSIP:ERROR:Parser parseMessage() | error parsing first line of SIP message: "" +15s
debug @ common.js:114
./node_modules/jssip/lib-es5/Parser.js.exports.parseMessage @ Parser.js:29
onTransportData @ UA.js:950
_onData @ Transport.js:303
_onMessage @ WebSocketInterface.js:151
试试这个:
this.coolPhone = new JsSIP.UA(configuration);
this.setUAEvent();
this.coolPhone.start();
setUAEvent(ua) {
this.coolPhone.on("newRTCSession", (e) => {
console.log("new rtc session", e);
const session = e.session;
session.on("progress", (message) => {
console.log("progress session ", message.response.status_code);
if (message.response.status_code === 180) //RINGING EXAMPLE
{
//put your code here
}
});
}