Class: Freeswitch::ESL::Client
- Inherits:
-
Connection
- Object
- Connection
- Freeswitch::ESL::Client
- Includes:
- Logger
- Defined in:
- lib/freeswitch/esl/client.rb
Overview
Inbound ESL client: connects to FreeSWITCH mod_event_socket.
Constant Summary
Constants inherited from Connection
Freeswitch::ESL::Connection::DEFAULT_TIMEOUT, Freeswitch::ESL::Connection::MSG_TERMINATOR
Instance Method Summary collapse
- #close ⇒ Object
- #config ⇒ Object
- #configure ⇒ Object
-
#initialize(freeswitch: {}, logger: nil) ⇒ Client
constructor
rubocop:disable Lint/MissingSuper.
- #on_reconnect(&block) ⇒ Object
Methods included from Logger
Methods inherited from Connection
#api, #bgapi, #closed?, #filter, #on, #send_command, #subscribe, #unsubscribe
Constructor Details
#initialize(freeswitch: {}, logger: nil) ⇒ Client
rubocop:disable Lint/MissingSuper
23 24 25 26 27 28 |
# File 'lib/freeswitch/esl/client.rb', line 23 def initialize(freeswitch: {}, logger: nil) # rubocop:disable Lint/MissingSuper @reconnect_handlers = [] @intentionally_closed = false configure(freeswitch:, logger:) end |
Instance Method Details
#close ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/freeswitch/esl/client.rb', line 30 def close logger.info "Closing FreeSWITCH ESL client connection" @intentionally_closed = true if @reconnect_thread # Stop reconnect thread now so it cannot keep running after close. @reconnect_thread.kill @reconnect_thread.join(0.1) end super end |
#config ⇒ Object
11 12 13 |
# File 'lib/freeswitch/esl/client.rb', line 11 def config @config ||= Freeswitch::ESL.configuration end |
#configure ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/freeswitch/esl/client.rb', line 15 def configure(**) close if instance_variable_defined?(:@socket) && @socket && !closed? @config = Freeswitch::ESL::Configuration.build(**) @intentionally_closed = false establish_connection self end |
#on_reconnect(&block) ⇒ Object
41 42 43 44 45 |
# File 'lib/freeswitch/esl/client.rb', line 41 def on_reconnect(&block) logger.debug "Registering FreeSWITCH ESL client reconnect handler" @reconnect_handlers << block self end |