Class: Quaff::TCPSIPEndpoint

Inherits:
BaseEndpoint show all
Defined in:
lib/endpoint.rb

Instance Attribute Summary collapse

Attributes inherited from BaseEndpoint

#msg_trace, #sdp_port, #sdp_socket, #uri

Instance Method Summary collapse

Methods inherited from BaseEndpoint

#add_call_id, #create_aka_client, #create_client, #create_server, #generate_call_id, #get_new_call_id, #get_new_message, #incoming_call, #initialize, #local_port, #mark_call_dead, #outgoing_call, #register, #send_msg, #set_aka_credentials, #setup_sdp, #unregister

Constructor Details

This class inherits a constructor from Quaff::BaseEndpoint

Instance Attribute Details

#socketsObject

Returns the value of attribute sockets.



157
158
159
# File 'lib/endpoint.rb', line 157

def sockets
  @sockets
end

Instance Method Details

#add_sock(sock) ⇒ Object



178
179
180
# File 'lib/endpoint.rb', line 178

def add_sock sock
  @sockets.push sock
end

#initialize_connectionObject



159
160
161
162
163
164
165
166
167
168
# File 'lib/endpoint.rb', line 159

def initialize_connection
  if @lport != :anyport
    @cxn = TCPServer.new(@lport)
  else
    @cxn = TCPServer.new(0)
    @lport = @cxn.addr[1]
  end
  @parser = SipParser.new
  @sockets = []
end

#new_source(host, port) ⇒ Object Also known as: new_connection



174
175
176
# File 'lib/endpoint.rb', line 174

def new_source host, port
  return TCPSource.new host, port
end

#terminateObject



182
183
184
185
186
187
188
189
# File 'lib/endpoint.rb', line 182

def terminate
  oldsockets = @sockets.dup
  @sockets = []
  oldsockets.each do |s| s.close unless s.closed? end
  mycxn = @cxn
  @cxn = nil
  mycxn.close
end

#transportObject



170
171
172
# File 'lib/endpoint.rb', line 170

def transport
  "TCP"
end