Class: Adhearsion::VoIP::Asterisk::AGI::Server
- Defined in:
- lib/adhearsion/voip/asterisk/agi_server.rb
Defined Under Namespace
Classes: RubyServer
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :server_class => RubyServer, :port => 4573, :host => "0.0.0.0" }
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#server_class ⇒ Object
readonly
Returns the value of attribute server_class.
Instance Method Summary collapse
- #graceful_shutdown ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #join ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
74 75 76 77 78 |
# File 'lib/adhearsion/voip/asterisk/agi_server.rb', line 74 def initialize( = {}) = DEFAULT_OPTIONS.merge @host, @port, @server_class = .values_at(:host, :port, :server_class) @server = server_class.new(port, host) end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
72 73 74 |
# File 'lib/adhearsion/voip/asterisk/agi_server.rb', line 72 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
72 73 74 |
# File 'lib/adhearsion/voip/asterisk/agi_server.rb', line 72 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
72 73 74 |
# File 'lib/adhearsion/voip/asterisk/agi_server.rb', line 72 def server @server end |
#server_class ⇒ Object (readonly)
Returns the value of attribute server_class.
72 73 74 |
# File 'lib/adhearsion/voip/asterisk/agi_server.rb', line 72 def server_class @server_class end |
Instance Method Details
#graceful_shutdown ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/adhearsion/voip/asterisk/agi_server.rb', line 85 def graceful_shutdown if @shutting_down server.stop return end @shutting_down = true while server.connections > 0 sleep 0.2 end server.stop end |
#join ⇒ Object
108 109 110 |
# File 'lib/adhearsion/voip/asterisk/agi_server.rb', line 108 def join server.join end |
#shutdown ⇒ Object
100 101 102 |
# File 'lib/adhearsion/voip/asterisk/agi_server.rb', line 100 def shutdown server.shutdown end |
#start ⇒ Object
80 81 82 83 |
# File 'lib/adhearsion/voip/asterisk/agi_server.rb', line 80 def start server.audit = true server.start end |
#stop ⇒ Object
104 105 106 |
# File 'lib/adhearsion/voip/asterisk/agi_server.rb', line 104 def stop server.stop end |