Class: Playwright::JsonPipeTransport
- Inherits:
-
Object
- Object
- Playwright::JsonPipeTransport
- Defined in:
- lib/playwright/json_pipe_transport.rb
Instance Method Summary collapse
- #async_run ⇒ Object
-
#initialize(local_utils, params) ⇒ JsonPipeTransport
constructor
A new instance of JsonPipeTransport.
- #on_driver_closed(&block) ⇒ Object
- #on_driver_crashed(&block) ⇒ Object
- #on_message_received(&block) ⇒ Object
- #send_message(message) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(local_utils, params) ⇒ JsonPipeTransport
Returns a new instance of JsonPipeTransport.
5 6 7 8 |
# File 'lib/playwright/json_pipe_transport.rb', line 5 def initialize(local_utils, params) @local_utils = local_utils @params = params end |
Instance Method Details
#async_run ⇒ Object
34 35 36 37 38 |
# File 'lib/playwright/json_pipe_transport.rb', line 34 def async_run @pipe = @local_utils.connect(@params) @pipe.channel.on('message', ->(params) { @on_message&.call(params['message']) }) @pipe.channel.on('closed', ->(_params) { @on_driver_closed&.call }) end |
#on_driver_closed(&block) ⇒ Object
14 15 16 |
# File 'lib/playwright/json_pipe_transport.rb', line 14 def on_driver_closed(&block) @on_driver_closed = block end |
#on_driver_crashed(&block) ⇒ Object
18 19 20 |
# File 'lib/playwright/json_pipe_transport.rb', line 18 def on_driver_crashed(&block) @on_driver_crashed = block end |
#on_message_received(&block) ⇒ Object
10 11 12 |
# File 'lib/playwright/json_pipe_transport.rb', line 10 def (&block) @on_message = block end |
#send_message(message) ⇒ Object
22 23 24 |
# File 'lib/playwright/json_pipe_transport.rb', line 22 def () @pipe.channel.('send', message: ) end |
#stop ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/playwright/json_pipe_transport.rb', line 26 def stop @pipe&.channel&.('close') rescue TargetClosedError nil ensure @pipe = nil end |