Class: OverSIP::SIP::NonInviteClientTransaction
Instance Attribute Summary
#connection, #core, #request, #state
Instance Method Summary
collapse
get_class
Methods included from Logger
fg_system_msg2str, load_methods, #log_id
Constructor Details
#initialize(core, request, transaction_conf, transport, ip = nil, ip_type = nil, port = nil) ⇒ NonInviteClientTransaction
Returns a new instance of NonInviteClientTransaction.
386
387
388
389
390
391
392
|
# File 'lib/oversip/sip/client_transaction.rb', line 386
def initialize core, request, transaction_conf, transport, ip=nil, ip_type=nil, port=nil
super
@log_id = "NICT #{@transaction_id}"
@state = :trying
end
|
Instance Method Details
#connection_failed ⇒ Object
540
541
542
543
544
545
546
|
# File 'lib/oversip/sip/client_transaction.rb', line 540
def connection_failed
@timer_F.cancel
@timer_E.cancel if @timer_E
terminate_transaction
@core.connection_failed
end
|
#receive_response(response) ⇒ Object
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
|
# File 'lib/oversip/sip/client_transaction.rb', line 496
def receive_response response
response.request = @request
response.tvars = @request.tvars
if response.status_code < 200
case @state
when :trying
@state = :proceeding
@core.receive_response(response) unless response.status_code == 100
return true
when :proceeding
@core.receive_response(response) unless response.status_code == 100
return true
else
log_system_notice "received a provisional response #{response.status_code} while in #{@state} state"
return false
end
elsif response.status_code >= 200
case @state
when :trying, :proceeding
@state = :completed
@timer_F.cancel
@timer_E.cancel if @timer_E
if @transport == :udp
start_timer_K
else
terminate_transaction
end
@core.receive_response(response)
return true
else
log_system_notice "received a final response #{response.status_code} while in #{@state} state"
return false
end
end
end
|
#retransmit_request ⇒ Object
492
493
494
|
# File 'lib/oversip/sip/client_transaction.rb', line 492
def retransmit_request
@connection.send_sip_msg @outgoing_request_str, @ip, @port
end
|
#send_request ⇒ Object
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
# File 'lib/oversip/sip/client_transaction.rb', line 394
def send_request
@client_transactions = @server_klass.non_invite_client_transactions
@client_transactions[@transaction_id] = self
@top_via = "#{@server_klass.via_core};branch=z9hG4bK#{@transaction_id};rport"
@request. "Via", @top_via
case @request.in_rr
when :rr
unless @request.connection.is_a?(@server_klass)
@out_rr = :rr
@request. "Record-Route", @server_klass.record_route
end
when :outgoing_outbound_rr
@out_rr = :rr
@request. "Record-Route", @server_klass.record_route
when :incoming_outbound_rr
@out_rr = :rr
@request. "Record-Route", "<sip:" << @request.route_outbound_flow_token << @server_klass.outbound_record_route_fragment
when :both_outbound_rr
@out_rr = :rr
@request. "Record-Route", "<sip:" << @request.route_outbound_flow_token << @server_klass.outbound_record_route_fragment
when :path
unless @request.connection.is_a?(@server_klass)
@out_rr = :path
@request. "Path", @server_klass.record_route
end
when :outgoing_outbound_path
@out_rr = :path
@request. "Path", @server_klass.record_route
when :incoming_outbound_path
@out_rr = :path
@request. "Path", "<sip:" << @request.route_outbound_flow_token << @server_klass.outbound_path_fragment
when :both_outbound_path
@out_rr = :rr
@request. "Path", "<sip:" << @request.route_outbound_flow_token << @server_klass.outbound_path_fragment
end if @core.is_a? ::OverSIP::SIP::Proxy
@outgoing_request_str = @request.to_s
@request. "Via"
case @out_rr
when :rr
@request. "Record-Route"
when :path
@request. "Path"
end
@connection.send_sip_msg @outgoing_request_str, @ip, @port
start_timer_E if @transport == :udp
start_timer_F
end
|
#start_timer_E ⇒ Object
457
458
459
460
461
462
463
464
465
466
467
468
|
# File 'lib/oversip/sip/client_transaction.rb', line 457
def start_timer_E
@timer_E_interval = TIMER_E
@timer_E = ::EM::PeriodicTimer.new(@timer_E_interval) do
log_system_debug "timer E expires, retransmitting request" if $oversip_debug
retransmit_request
if @state == :trying
@timer_E_interval = @timer_E.interval = [2*@timer_E_interval, T2].min
else
@timer_E_interval = @timer_E.interval = T2
end
end
end
|
#start_timer_F ⇒ Object
470
471
472
473
474
475
476
477
|
# File 'lib/oversip/sip/client_transaction.rb', line 470
def start_timer_F
@timer_F = ::EM::Timer.new(@transaction_conf[:timer_F] || TIMER_F) do
log_system_debug "timer F expires, transaction timeout" if $oversip_debug
@timer_E.cancel if @timer_E
terminate_transaction
@core.client_timeout
end
end
|
#start_timer_K ⇒ Object
479
480
481
482
483
484
|
# File 'lib/oversip/sip/client_transaction.rb', line 479
def start_timer_K
::EM.add_timer(TIMER_K_UDP) do
log_system_debug "timer K expires, transaction terminated" if $oversip_debug
terminate_transaction
end
end
|
#terminate_transaction ⇒ Object
Terminate current transaction and delete from the list of transactions.
487
488
489
490
|
# File 'lib/oversip/sip/client_transaction.rb', line 487
def terminate_transaction
@state = :terminated
@client_transactions.delete(@transaction_id)
end
|
#tls_validation_failed ⇒ Object
548
549
550
551
552
553
554
|
# File 'lib/oversip/sip/client_transaction.rb', line 548
def tls_validation_failed
@timer_F.cancel
@timer_E.cancel if @timer_E
terminate_transaction
@core.tls_validation_failed
end
|