From 3f84b30ac2702cce2e259158851189f7c7bc87c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 18 Mar 2013 16:03:57 +0100 Subject: [PATCH] Make RTCSession local_identity and remote_identity NameAddrHeader instances --- src/RTCSession.js | 16 ++++++++-------- src/SIPMessage.js | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/RTCSession.js b/src/RTCSession.js index 1f48fa242..93306b89d 100644 --- a/src/RTCSession.js +++ b/src/RTCSession.js @@ -540,7 +540,7 @@ RTCSession.prototype.connect = function(target, options) { //Save the session into the ua sessions collection. this.ua.sessions[this.id] = this; - this.newRTCSession('local', this.request, target); + this.newRTCSession('local', this.request); if (invalidTarget) { this.failed('local', null, JsSIP.C.causes.INVALID_TARGET); @@ -968,18 +968,18 @@ RTCSession.prototype.onRequestTimeout = function() { /** * @private */ -RTCSession.prototype.newRTCSession = function(originator, request, target) { +RTCSession.prototype.newRTCSession = function(originator, request) { var session = this, event_name = 'newRTCSession'; - session.direction = (originator === 'local') ? 'outgoing' : 'incoming'; - if (originator === 'remote') { - session.local_identity = request.to.uri; - session.remote_identity = request.from.uri; + session.direction = 'incoming'; + session.local_identity = request.to; + session.remote_identity = request.from; } else if (originator === 'local'){ - session.local_identity = session.ua.configuration.uri; - session.remote_identity = target; + session.direction = 'outgoing'; + session.local_identity = request.from; + session.remote_identity = request.to; } session.ua.emit(event_name, session.ua, { diff --git a/src/SIPMessage.js b/src/SIPMessage.js index 8bcd451ff..95cefde7c 100644 --- a/src/SIPMessage.js +++ b/src/SIPMessage.js @@ -62,6 +62,7 @@ OutgoingRequest = function(method, ruri, ua, params, extraHeaders, body) { to = (params.to_display_name || params.to_display_name === 0) ? '"' + params.to_display_name + '" ' : ''; to += '<' + (params.to_uri || ruri) + '>'; to += params.to_tag ? ';tag=' + params.to_tag : ''; + this.to = new JsSIP.NameAddrHeader.parse(to); this.setHeader('to', to); // From @@ -74,6 +75,7 @@ OutgoingRequest = function(method, ruri, ua, params, extraHeaders, body) { } from += '<' + (params.from_uri || ua.configuration.uri) + '>;tag='; from += params.from_tag || JsSIP.Utils.newTag(); + this.from = new JsSIP.NameAddrHeader.parse(from); this.setHeader('from', from); // Call-ID