Class: ChromeRemote::WebSocketClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ WebSocketClient

Returns a new instance of WebSocketClient.



8
9
10
11
12
13
14
15
16
17
# File 'lib/chrome_remote/web_socket_client.rb', line 8

def initialize(url)
  @socket = ChromeRemote::Socket.new(url)
  @driver = ::WebSocket::Driver.client(socket)

  @messages = []
  @status = :closed

  setup_driver
  start_driver
end

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



6
7
8
# File 'lib/chrome_remote/web_socket_client.rb', line 6

def driver
  @driver
end

#messagesObject (readonly)

Returns the value of attribute messages.



6
7
8
# File 'lib/chrome_remote/web_socket_client.rb', line 6

def messages
  @messages
end

#socketObject (readonly)

Returns the value of attribute socket.



6
7
8
# File 'lib/chrome_remote/web_socket_client.rb', line 6

def socket
  @socket
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/chrome_remote/web_socket_client.rb', line 6

def status
  @status
end

Instance Method Details

#read_msgObject



23
24
25
26
# File 'lib/chrome_remote/web_socket_client.rb', line 23

def read_msg
  parse_input until msg = messages.shift
  msg
end

#send_msg(msg) ⇒ Object



19
20
21
# File 'lib/chrome_remote/web_socket_client.rb', line 19

def send_msg(msg)
  driver.text msg
end