Class: Billy::Proxy
- Inherits:
-
Object
- Object
- Billy::Proxy
- Extended by:
- Forwardable
- Defined in:
- lib/billy/proxy.rb
Instance Attribute Summary collapse
-
#request_handler ⇒ Object
readonly
Returns the value of attribute request_handler.
Instance Method Summary collapse
- #cache ⇒ Object
- #host ⇒ Object
-
#initialize ⇒ Proxy
constructor
A new instance of Proxy.
- #port ⇒ Object
- #start(threaded = true) ⇒ Object
- #stop ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize ⇒ Proxy
Returns a new instance of Proxy.
12 13 14 15 |
# File 'lib/billy/proxy.rb', line 12 def initialize @request_handler = Billy::RequestHandler.new reset end |
Instance Attribute Details
#request_handler ⇒ Object (readonly)
Returns the value of attribute request_handler.
8 9 10 |
# File 'lib/billy/proxy.rb', line 8 def request_handler @request_handler end |
Instance Method Details
#host ⇒ Object
38 39 40 |
# File 'lib/billy/proxy.rb', line 38 def host Billy.config.proxy_host end |
#port ⇒ Object
42 43 44 |
# File 'lib/billy/proxy.rb', line 42 def port Socket.unpack_sockaddr_in(EM.get_sockname(@signature)).first end |
#start(threaded = true) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/billy/proxy.rb', line 17 def start(threaded = true) if threaded Thread.new { main_loop } sleep(0.01) while (not defined?(@signature)) || @signature.nil? else main_loop end end |
#stop ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/billy/proxy.rb', line 26 def stop return if @signature.nil? server_port = port EM.stop wait_for_server_shutdown! server_port end |
#url ⇒ Object
34 35 36 |
# File 'lib/billy/proxy.rb', line 34 def url "http://#{host}:#{port}" end |