Class: OverSIP::SIP::TcpServer
- Inherits:
-
TcpConnection
- Object
- EM::Connection
- Connection
- TcpConnection
- OverSIP::SIP::TcpServer
- Defined in:
- lib/oversip/sip/listeners/tcp_server.rb
Direct Known Subclasses
Constant Summary
Constants inherited from TcpConnection
OverSIP::SIP::TcpConnection::HEADERS_MAX_SIZE
Constants included from MessageProcessor
Instance Attribute Summary collapse
-
#outbound_flow_token ⇒ Object
readonly
Returns the value of attribute outbound_flow_token.
Attributes inherited from Connection
Instance Method Summary collapse
Methods inherited from TcpConnection
#get_body, #parse_headers, #process_received_data, #receive_data, #remote_ip, #remote_ip_type, #remote_port, #send_sip_msg
Methods inherited from Connection
#initialize, #open?, outbound_listener?, #receive_senderror, reliable_transport_listener?, #transport
Methods included from Logger
fg_system_msg2str, load_methods, #log_id
Constructor Details
This class inherits a constructor from OverSIP::SIP::Connection
Instance Attribute Details
#outbound_flow_token ⇒ Object (readonly)
Returns the value of attribute outbound_flow_token.
5 6 7 |
# File 'lib/oversip/sip/listeners/tcp_server.rb', line 5 def outbound_flow_token @outbound_flow_token end |
Instance Method Details
#post_connection ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/oversip/sip/listeners/tcp_server.rb', line 7 def post_connection begin @remote_port, @remote_ip = ::Socket.unpack_sockaddr_in(get_peername) rescue => e log_system_error "error obtaining remote IP/port (#{e.class}: #{e.}), closing connection" close_connection @state = :ignore return end @connection_id = ::OverSIP::SIP::TransportManager.add_connection self, self.class, self.class.ip_type, @remote_ip, @remote_port # Create an Outbound (RFC 5626) flow token for this connection. @outbound_flow_token = ::OverSIP::SIP::TransportManager.add_outbound_connection self ### Testing TCP keepalive. # https://github.com/bklang/eventmachine/commit/74c65a56c733bc1b6f092e32a9f0d722501ade46 # http://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/ if ::OverSIP::SIP.tcp_keepalive_interval set_sock_opt Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true set_sock_opt Socket::SOL_TCP, Socket::TCP_KEEPIDLE, ::OverSIP::SIP.tcp_keepalive_interval # First TCP ping. set_sock_opt Socket::SOL_TCP, Socket::TCP_KEEPINTVL, ::OverSIP::SIP.tcp_keepalive_interval # Interval between TCP pings. end log_system_debug("connection opened from " << remote_desc) if $oversip_debug end |
#remote_desc(force = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/oversip/sip/listeners/tcp_server.rb', line 34 def remote_desc force=nil if force @remote_desc = case @remote_ip_type when :ipv4 ; "#{@remote_ip}:#{@remote_port.to_s}" when :ipv6 ; "[#{@remote_ip}]:#{@remote_port.to_s}" end else @remote_desc ||= case self.class.ip_type when :ipv4 ; "#{@remote_ip}:#{@remote_port.to_s}" when :ipv6 ; "[#{@remote_ip}]:#{@remote_port.to_s}" end end end |
#unbind(cause = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/oversip/sip/listeners/tcp_server.rb', line 49 def unbind cause=nil @state = :ignore # Remove the connection. self.class.connections.delete @connection_id # Remove the Outbound token flow. ::OverSIP::SIP::TransportManager.delete_outbound_connection @outbound_flow_token @local_closed = true if cause == ::Errno::ETIMEDOUT if $oversip_debug log_msg = "connection from #{remote_desc} " log_msg << ( @local_closed ? "locally closed" : "remotely closed" ) log_msg << " (cause: #{cause.inspect})" if cause log_system_debug log_msg end unless $! end |