Class: Devproxy::Connection
- Inherits:
-
Struct
- Object
- Struct
- Devproxy::Connection
- Defined in:
- lib/devproxy/connection.rb
Direct Known Subclasses
Constant Summary collapse
- MAX_DOTS =
60
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options) ⇒ Connection
constructor
A new instance of Connection.
- #loop! ⇒ Object
- #on_close ⇒ Object
- #on_connected(proxy) ⇒ Object
- #on_heartbeat(data) ⇒ Object
- #on_stderr(data) ⇒ Object
- #on_stdout(data) ⇒ Object
- #stop! ⇒ Object
Constructor Details
#initialize(options) ⇒ Connection
Returns a new instance of Connection.
7 8 9 10 |
# File 'lib/devproxy/connection.rb', line 7 def initialize super reset_dots! end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options
4 5 6 |
# File 'lib/devproxy/connection.rb', line 4 def @options end |
Instance Method Details
#loop! ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/devproxy/connection.rb', line 12 def loop! @session.shutdown! if @session @session = create_session @session.loop! if @session rescue Errno::ECONNREFUSED on_stderr "CONNECTION REFUSED. Is there anything listening on port #{.port}?" retry end |
#on_close ⇒ Object
49 50 51 |
# File 'lib/devproxy/connection.rb', line 49 def on_close stop! end |
#on_connected(proxy) ⇒ Object
25 26 27 |
# File 'lib/devproxy/connection.rb', line 25 def on_connected(proxy) $stdout.puts "Tunneling requests from https://#{proxy}.#{.app_host} to #{.listen} port #{.port}" end |
#on_heartbeat(data) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/devproxy/connection.rb', line 29 def on_heartbeat data return unless .verbose $stdout.write "." if (@dotno += 1) % MAX_DOTS == 0 $stdout.write "\n" end end |
#on_stderr(data) ⇒ Object
43 44 45 46 47 |
# File 'lib/devproxy/connection.rb', line 43 def on_stderr data $stdout.write("\n") if .verbose $stderr.puts(data) reset_dots! end |
#on_stdout(data) ⇒ Object
37 38 39 40 41 |
# File 'lib/devproxy/connection.rb', line 37 def on_stdout data $stdout.write("\n") if .verbose $stdout.puts(data) reset_dots! end |
#stop! ⇒ Object
21 22 23 |
# File 'lib/devproxy/connection.rb', line 21 def stop! @session.stop! if @session end |