Class: Camoufox::SyncAPI::NodeRunner::Session
- Inherits:
-
Object
- Object
- Camoufox::SyncAPI::NodeRunner::Session
- Defined in:
- lib/camoufox/sync_api.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(launch_options) ⇒ Session
constructor
A new instance of Session.
- #request(action, params = {}) ⇒ Object
Constructor Details
#initialize(launch_options) ⇒ Session
Returns a new instance of Session.
114 115 116 117 118 119 120 |
# File 'lib/camoufox/sync_api.rb', line 114 def initialize() = @command_id = 0 @closed = false spawn_session wait_for_ready end |
Instance Method Details
#close ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/camoufox/sync_api.rb', line 135 def close return if @closed begin request('close') rescue NodeExecutionFailed # swallow shutdown errors ensure @closed = true cleanup end end |
#request(action, params = {}) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/camoufox/sync_api.rb', line 122 def request(action, params = {}) raise Camoufox::Error, "Page session is closed" if @closed @command_id += 1 payload = { 'id' => @command_id, 'action' => action, 'params' => params, } (payload) handle_response(@command_id) end |