Class: Playwright::Channel

Inherits:
Object
  • Object
show all
Includes:
EventEmitter
Defined in:
lib/playwright/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EventEmitter

#emit, #off, #on, #once

Constructor Details

#initialize(connection, guid, object:) ⇒ Channel

Returns a new instance of Channel.

Parameters:



8
9
10
11
12
# File 'lib/playwright/channel.rb', line 8

def initialize(connection, guid, object:)
  @connection = connection
  @guid = guid
  @object = object
end

Instance Attribute Details

#guidObject (readonly)

Returns the value of attribute guid.



14
15
16
# File 'lib/playwright/channel.rb', line 14

def guid
  @guid
end

#objectObject (readonly)

Returns the value of attribute object.



14
15
16
# File 'lib/playwright/channel.rb', line 14

def object
  @object
end

Instance Method Details

#async_send_message_to_server(method, params = {}) ⇒ Object

Parameters:

  • method (String)
  • params (Hash) (defaults to: {})


41
42
43
44
45
# File 'lib/playwright/channel.rb', line 41

def async_send_message_to_server(method, params = {})
  with_logging do ||
    @connection.async_send_message_to_server(@guid, method, params, metadata: )
  end
end

#send_message_to_server(method, params = {}) ⇒ Playwright::ChannelOwner|nil

Parameters:

  • method (String)
  • params (Hash) (defaults to: {})

Returns:



19
20
21
22
23
24
25
26
27
# File 'lib/playwright/channel.rb', line 19

def send_message_to_server(method, params = {})
  result = send_message_to_server_result(method, params)
  if result.is_a?(Hash)
    _type, channel_owner = result.first
    channel_owner
  else
    nil
  end
end

#send_message_to_server_result(method, params) ⇒ Hash

Parameters:

  • method (String)
  • params (Hash)

Returns:

  • (Hash)


32
33
34
35
36
# File 'lib/playwright/channel.rb', line 32

def send_message_to_server_result(method, params)
  with_logging do ||
    @connection.send_message_to_server(@guid, method, params, metadata: )
  end
end