mixin only methods for directing the driver

patch bump
This commit is contained in:
onyx-and-iris 2023-07-26 16:55:59 +01:00
parent 2883fd42cc
commit d15418a660
3 changed files with 31 additions and 29 deletions

View File

@ -10,7 +10,7 @@ require_relative "mixin"
module OBSWS
class Base
include Logging
include Driver
include Driver::Director
include Mixin::OPCodes
attr_reader :closed

View File

@ -16,36 +16,38 @@ module OBSWS
end
end
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
private def start_driver
Thread.new do
@driver.start
loop do
@driver.parse(@socket.readpartial(4096))
rescue EOFError
break
module Director
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
end
public def stop_driver
@driver.close
private def start_driver
Thread.new do
@driver.start
loop do
@driver.parse(@socket.readpartial(4096))
rescue EOFError
break
end
end
end
public def stop_driver
@driver.close
end
end
end
end

View File

@ -11,7 +11,7 @@ module OBSWS
end
def patch
1
2
end
def to_a