Class: Netpump::Client
- Inherits:
-
Object
- Object
- Netpump::Client
- Defined in:
- lib/netpump/client.rb
Instance Method Summary collapse
-
#initialize(mode: "direct", host: "0.0.0.0", port: "8080", proxy_host: "127.0.0.1", proxy_port: 3128, server_url: "wss://weblink-ouux.onrender.com", connection_inactivity_timeout: 30.0, websocket_pool_size: 20, websocket_pool_timeout: 60.0) ⇒ Client
constructor
A new instance of Client.
- #start ⇒ Object
Constructor Details
#initialize(mode: "direct", host: "0.0.0.0", port: "8080", proxy_host: "127.0.0.1", proxy_port: 3128, server_url: "wss://weblink-ouux.onrender.com", connection_inactivity_timeout: 30.0, websocket_pool_size: 20, websocket_pool_timeout: 60.0) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/netpump/client.rb', line 12 def initialize( mode: "direct", host: "0.0.0.0", port: "8080", proxy_host: "127.0.0.1", proxy_port: 3128, server_url: "wss://weblink-ouux.onrender.com", connection_inactivity_timeout: 30.0, websocket_pool_size: 20, websocket_pool_timeout: 60.0 ) @mode = mode @host = host if mode == "browser" @port = port if mode == "browser" @proxy_host = proxy_host @proxy_port = proxy_port @server_url = URI(server_url) @connection_inactivity_timeout = connection_inactivity_timeout @websocket_pool = EventMachine::Queue.new @websocket_pool_size = websocket_pool_size @websocket_pool_timeout = websocket_pool_timeout @control_ws = nil @log = lambda { |msg, **ctx| log(msg, c: true, **ctx) } @ready = EventMachine::Completion.new end |
Instance Method Details
#start ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/netpump/client.rb', line 38 def start @log.call "[+] netpump client is starting.", mode: @mode, host: @host, port: @port case @mode when "direct" start_proxy_server @ready.succeed when "browser" start_websocket_server print_open_url end @ready end |