Module: OBSWS::Driver::Director

Included in:
Base
Defined in:
lib/obsws/driver.rb

Instance Method Summary collapse

Instance Method Details

#setup_driver(host, port) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/obsws/driver.rb', line 17

def setup_driver(host, port)
  @socket = TCPSocket.new(host, port)
  @driver =
    WebSocket::Driver.client(Socket.new("ws://#{host}:#{port}", @socket))
  @driver.on :open do |msg|
    logger.debug("driver socket open")
  end
  @driver.on :close do |msg|
    logger.debug("driver socket closed")
    @closed = true
  end
  @driver.on :message do |msg|
    msg_handler(JSON.parse(msg.data, symbolize_names: true))
  end
end

#stop_driverObject



45
46
47
# File 'lib/obsws/driver.rb', line 45

public def stop_driver
  @driver.close
end