class Playwright::WebSocketClient::DriverImpl

providing #url, #write(string)

def disconnect

def disconnect
  @socket.close
end

def initialize(url)

providing #url, #write(string)
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

def readpartial(maxlen = 1024)

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

def write(data)

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