Class: Playwright::WebSocketClient::DriverImpl

Inherits:
Object
  • Object
show all
Defined in:
lib/playwright/web_socket_client.rb

Overview

providing #url, #write(string)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ DriverImpl

Returns a new instance of DriverImpl.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/playwright/web_socket_client.rb', line 27

def initialize(url)
  @url = url

  endpoint = URI.parse(url)
  @socket =
    if endpoint.scheme == 'wss'
      SecureSocketFactory.new(endpoint.host, endpoint.port).create
    else
      TCPSocket.new(endpoint.host, endpoint.port)
    end
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



39
40
41
# File 'lib/playwright/web_socket_client.rb', line 39

def url
  @url
end

Instance Method Details

#disconnectObject



55
56
57
# File 'lib/playwright/web_socket_client.rb', line 55

def disconnect
  @socket.close
end

#readpartial(maxlen = 1024) ⇒ Object



49
50
51
52
53
# File 'lib/playwright/web_socket_client.rb', line 49

def readpartial(maxlen = 1024)
  @socket.readpartial(maxlen)
rescue Errno::ECONNRESET
  raise EOFError.new('closed by remote')
end

#write(data) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/playwright/web_socket_client.rb', line 41

def write(data)
  @socket.write(data)
rescue Errno::EPIPE
  raise EOFError.new('already closed')
rescue Errno::ECONNRESET
  raise EOFError.new('closed by remote')
end