3434*/
3535var NonInviteClientTransaction = function ( request_sender , request , transport ) {
3636 var via ,
37+ via_transport ,
3738 events = [ 'stateChanged' ] ;
3839
3940 this . type = C . NON_INVITE_CLIENT ;
@@ -44,7 +45,17 @@ var NonInviteClientTransaction = function(request_sender, request, transport) {
4445
4546 this . logger = request_sender . ua . getLogger ( 'jssip.transaction.nict' , this . id ) ;
4647
47- via = 'SIP/2.0/' + ( request_sender . ua . configuration . hack_via_tcp ? 'TCP' : transport . server . scheme ) ;
48+ if ( request_sender . ua . configuration . hack_via_tcp ) {
49+ via_transport = 'TCP' ;
50+ }
51+ else if ( request_sender . ua . configuration . hack_via_ws ) {
52+ via_transport = 'WS' ;
53+ }
54+ else {
55+ via_transport = transport . server . scheme ;
56+ }
57+
58+ via = 'SIP/2.0/' + via_transport ;
4859 via += ' ' + request_sender . ua . configuration . via_host + ';branch=' + this . id ;
4960
5061 this . request . setHeader ( 'via' , via ) ;
@@ -138,6 +149,7 @@ NonInviteClientTransaction.prototype.receiveResponse = function(response) {
138149var InviteClientTransaction = function ( request_sender , request , transport ) {
139150 var via ,
140151 tr = this ,
152+ via_transport ,
141153 events = [ 'stateChanged' ] ;
142154
143155 this . type = C . INVITE_CLIENT ;
@@ -148,7 +160,17 @@ var InviteClientTransaction = function(request_sender, request, transport) {
148160
149161 this . logger = request_sender . ua . getLogger ( 'jssip.transaction.ict' , this . id ) ;
150162
151- via = 'SIP/2.0/' + ( request_sender . ua . configuration . hack_via_tcp ? 'TCP' : transport . server . scheme ) ;
163+ if ( request_sender . ua . configuration . hack_via_tcp ) {
164+ via_transport = 'TCP' ;
165+ }
166+ else if ( request_sender . ua . configuration . hack_via_ws ) {
167+ via_transport = 'WS' ;
168+ }
169+ else {
170+ via_transport = transport . server . scheme ;
171+ }
172+
173+ via = 'SIP/2.0/' + via_transport ;
152174 via += ' ' + request_sender . ua . configuration . via_host + ';branch=' + this . id ;
153175
154176 this . request . setHeader ( 'via' , via ) ;
@@ -329,7 +351,8 @@ InviteClientTransaction.prototype.receiveResponse = function(response) {
329351 * @param {JsSIP.Transport } transport
330352 */
331353var AckClientTransaction = function ( request_sender , request , transport ) {
332- var via ;
354+ var via ,
355+ via_transport ;
333356
334357 this . transport = transport ;
335358 this . id = 'z9hG4bK' + Math . floor ( Math . random ( ) * 10000000 ) ;
@@ -338,7 +361,17 @@ var AckClientTransaction = function(request_sender, request, transport) {
338361
339362 this . logger = request_sender . ua . getLogger ( 'jssip.transaction.nict' , this . id ) ;
340363
341- via = 'SIP/2.0/' + ( request_sender . ua . configuration . hack_via_tcp ? 'TCP' : transport . server . scheme ) ;
364+ if ( request_sender . ua . configuration . hack_via_tcp ) {
365+ via_transport = 'TCP' ;
366+ }
367+ else if ( request_sender . ua . configuration . hack_via_ws ) {
368+ via_transport = 'WS' ;
369+ }
370+ else {
371+ via_transport = transport . server . scheme ;
372+ }
373+
374+ via = 'SIP/2.0/' + via_transport ;
342375 via += ' ' + request_sender . ua . configuration . via_host + ';branch=' + this . id ;
343376
344377 this . request . setHeader ( 'via' , via ) ;
@@ -398,7 +431,7 @@ NonInviteServerTransaction.prototype.timer_J = function() {
398431NonInviteServerTransaction . prototype . onTransportError = function ( ) {
399432 if ( ! this . transportError ) {
400433 this . transportError = true ;
401-
434+
402435 this . logger . log ( 'transport error occurred, deleting non-INVITE server transaction ' + this . id ) ;
403436
404437 window . clearTimeout ( this . J ) ;
@@ -483,7 +516,7 @@ var InviteServerTransaction = function(request, ua) {
483516 ua . newTransaction ( this ) ;
484517
485518 this . resendProvisionalTimer = null ;
486-
519+
487520 request . reply ( 100 ) ;
488521
489522 this . initEvents ( events ) ;
@@ -501,7 +534,7 @@ InviteServerTransaction.prototype.timer_H = function() {
501534 if ( this . state === C . STATUS_COMPLETED ) {
502535 this . logger . warn ( 'transactions' , 'ACK for INVITE server transaction was never received, call will be terminated' ) ;
503536 }
504-
537+
505538 this . stateChanged ( C . STATUS_TERMINATED ) ;
506539 this . ua . destroyTransaction ( this ) ;
507540} ;
@@ -531,11 +564,11 @@ InviteServerTransaction.prototype.onTransportError = function() {
531564 window . clearInterval ( this . resendProvisionalTimer ) ;
532565 this . resendProvisionalTimer = null ;
533566 }
534-
567+
535568 window . clearTimeout ( this . L ) ;
536569 window . clearTimeout ( this . H ) ;
537570 window . clearTimeout ( this . I ) ;
538-
571+
539572 this . stateChanged ( C . STATUS_TERMINATED ) ;
540573 this . ua . destroyTransaction ( this ) ;
541574 }
@@ -576,7 +609,7 @@ InviteServerTransaction.prototype.receiveResponse = function(status_code, respon
576609 this . L = window . setTimeout ( function ( ) {
577610 tr . timer_L ( ) ;
578611 } , JsSIP . Timers . TIMER_L ) ;
579-
612+
580613 if ( this . resendProvisionalTimer !== null ) {
581614 window . clearInterval ( this . resendProvisionalTimer ) ;
582615 this . resendProvisionalTimer = null ;
@@ -601,7 +634,7 @@ InviteServerTransaction.prototype.receiveResponse = function(status_code, respon
601634 window . clearInterval ( this . resendProvisionalTimer ) ;
602635 this . resendProvisionalTimer = null ;
603636 }
604-
637+
605638 if ( ! this . transport . send ( response ) ) {
606639 this . onTransportError ( ) ;
607640 if ( onFailure ) {
0 commit comments