@@ -76,15 +76,6 @@ JsSIP.Session.prototype.init_incoming = function(request) {
7676JsSIP . Session . prototype . connect = function ( target , views , options ) {
7777 var event , eventHandlers , request , selfView , remoteView , mediaTypes , extraHeaders , requestParams ;
7878
79- // Check UA Status
80- JsSIP . Utils . checkUAStatus ( this . ua ) ;
81-
82- // Check WebRTC support
83- if ( ! JsSIP . WebRTC . isSupported ) {
84- console . log ( JsSIP . C . LOG_UA + 'WebRTC not supported.' ) ;
85- throw new JsSIP . Exceptions . WebRtcNotSupportedError ( ) ;
86- }
87-
8879 // Check Session Status
8980 if ( this . status !== JsSIP . C . SESSION_NULL ) {
9081 throw new JsSIP . Exceptions . InvalidStateError ( this . status ) ;
@@ -110,7 +101,11 @@ JsSIP.Session.prototype.connect = function(target, views, options) {
110101 }
111102
112103 // Check target validity
113- target = JsSIP . Utils . normalizeURI ( target , this . ua . configuration . domain ) ;
104+ try {
105+ target = JsSIP . Utils . normalizeURI ( target , this . ua . configuration . domain ) ;
106+ } catch ( e ) {
107+ target = JsSIP . C . INVALID_TARGET ;
108+ }
114109
115110 // Session parameter initialization
116111 this . from_tag = JsSIP . Utils . newTag ( ) ;
@@ -152,7 +147,14 @@ JsSIP.Session.prototype.connect = function(target, views, options) {
152147
153148 this . newSession ( 'local' , request , target ) ;
154149 this . connecting ( 'local' , request , target ) ;
155- this . sendInitialRequest ( mediaTypes ) ;
150+
151+ if ( target === JsSIP . C . INVALID_TARGET ) {
152+ this . failed ( 'local' , null , JsSIP . C . causes . INVALID_TARGET ) ;
153+ } else if ( ! JsSIP . WebRTC . isSupported ) {
154+ this . failed ( 'local' , null , JsSIP . C . causes . WEBRTC_NOT_SUPPORTED ) ;
155+ } else {
156+ this . sendInitialRequest ( mediaTypes ) ;
157+ }
156158} ;
157159
158160/**
0 commit comments