mirror of
https://github.com/onyx-and-iris/obsws-ruby.git
synced 2025-01-18 13:30:48 +00:00
mixin only methods for directing the driver
patch bump
This commit is contained in:
parent
2883fd42cc
commit
d15418a660
@ -10,7 +10,7 @@ require_relative "mixin"
|
||||
module OBSWS
|
||||
class Base
|
||||
include Logging
|
||||
include Driver
|
||||
include Driver::Director
|
||||
include Mixin::OPCodes
|
||||
|
||||
attr_reader :closed
|
||||
|
@ -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
|
||||
|
@ -11,7 +11,7 @@ module OBSWS
|
||||
end
|
||||
|
||||
def patch
|
||||
1
|
||||
2
|
||||
end
|
||||
|
||||
def to_a
|
||||
|
Loading…
Reference in New Issue
Block a user