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
|
module OBSWS
|
||||||
class Base
|
class Base
|
||||||
include Logging
|
include Logging
|
||||||
include Driver
|
include Driver::Director
|
||||||
include Mixin::OPCodes
|
include Mixin::OPCodes
|
||||||
|
|
||||||
attr_reader :closed
|
attr_reader :closed
|
||||||
|
@ -16,36 +16,38 @@ module OBSWS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_driver(host, port)
|
module Director
|
||||||
@socket = TCPSocket.new(host, port)
|
def setup_driver(host, port)
|
||||||
@driver =
|
@socket = TCPSocket.new(host, port)
|
||||||
WebSocket::Driver.client(Socket.new("ws://#{host}:#{port}", @socket))
|
@driver =
|
||||||
@driver.on :open do |msg|
|
WebSocket::Driver.client(Socket.new("ws://#{host}:#{port}", @socket))
|
||||||
logger.debug("driver socket open")
|
@driver.on :open do |msg|
|
||||||
end
|
logger.debug("driver socket open")
|
||||||
@driver.on :close do |msg|
|
end
|
||||||
logger.debug("driver socket closed")
|
@driver.on :close do |msg|
|
||||||
@closed = true
|
logger.debug("driver socket closed")
|
||||||
end
|
@closed = true
|
||||||
@driver.on :message do |msg|
|
end
|
||||||
msg_handler(JSON.parse(msg.data, symbolize_names: true))
|
@driver.on :message do |msg|
|
||||||
end
|
msg_handler(JSON.parse(msg.data, symbolize_names: true))
|
||||||
end
|
|
||||||
|
|
||||||
private def start_driver
|
|
||||||
Thread.new do
|
|
||||||
@driver.start
|
|
||||||
|
|
||||||
loop do
|
|
||||||
@driver.parse(@socket.readpartial(4096))
|
|
||||||
rescue EOFError
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
public def stop_driver
|
private def start_driver
|
||||||
@driver.close
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ module OBSWS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def patch
|
def patch
|
||||||
1
|
2
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_a
|
def to_a
|
||||||
|
Loading…
Reference in New Issue
Block a user