mirror of
https://github.com/onyx-and-iris/obsws-ruby.git
synced 2026-04-18 21:43:32 +00:00
assign client updater methods as base lambdas
This commit is contained in:
@@ -15,7 +15,9 @@ module OBSWS
|
||||
def initialize(**kwargs)
|
||||
@base_client = Base.new(**kwargs)
|
||||
LOGGER.info("#{self} succesfully identified with server")
|
||||
@base_client.add_observer(self)
|
||||
@base_client.updater = ->(op_code, data) {
|
||||
@response = data if op_code == Mixin::OPCodes::REQUESTRESPONSE
|
||||
}
|
||||
@response = {requestId: 0}
|
||||
end
|
||||
|
||||
@@ -26,7 +28,7 @@ module OBSWS
|
||||
def run
|
||||
yield(self)
|
||||
ensure
|
||||
close
|
||||
stop_driver
|
||||
WaitUtil.wait_for_condition(
|
||||
"driver to close",
|
||||
delay_sec: 0.01,
|
||||
@@ -34,10 +36,6 @@ module OBSWS
|
||||
) { @base_client.closed }
|
||||
end
|
||||
|
||||
def update(op_code, data)
|
||||
@response = data if op_code == Mixin::OPCodes::REQUESTRESPONSE
|
||||
end
|
||||
|
||||
def call(req, data = nil)
|
||||
id = rand(1..1000)
|
||||
@base_client.req(id, req, data)
|
||||
|
||||
Reference in New Issue
Block a user