assign client updater methods as base lambdas

This commit is contained in:
2023-07-26 10:51:38 +01:00
parent 18d291c6eb
commit 9940fbbf9f
3 changed files with 22 additions and 22 deletions

View File

@@ -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)