From 60b87205c0e988a341d32624dec80504ee8b27d6 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Sun, 23 Oct 2022 23:33:30 +0100 Subject: [PATCH 1/2] don't pass auth token if authentication disabled --- lib/obsws/base.rb | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/obsws/base.rb b/lib/obsws/base.rb index 1efe89f..6f711b1 100644 --- a/lib/obsws/base.rb +++ b/lib/obsws/base.rb @@ -50,10 +50,10 @@ module OBSWS end start_driver WaitUtil.wait_for_condition( - "waiting authentication successful", + "waiting successful identification", delay_sec: 0.01, timeout_sec: 3 - ) { @authenticated } + ) { @identified } end def start_driver @@ -74,32 +74,33 @@ module OBSWS ) end - def authenticate(auth) - token = auth_token(**auth) + def authenticate(auth = nil) payload = { op: Mixin::OPCodes::IDENTIFY, d: { rpcVersion: 1, - authentication: token, eventSubscriptions: @subs } } - LOGGER.debug("initiating authentication") + payload[:d][:authentication] = auth_token(**auth) if auth @driver.text(JSON.generate(payload)) end def msg_handler(data) - op_code = data[:op] - case op_code + case data[:op] when Mixin::OPCodes::HELLO - LOGGER.debug("hello received, passing to auth") + if data[:d].key? :authentication + LOGGER.debug("initiating authentication") + else + LOGGER.debug("authentication disabled... skipping.") + end authenticate(data[:d][:authentication]) when Mixin::OPCodes::IDENTIFIED - LOGGER.debug("authentication successful") - @authenticated = true + LOGGER.debug("client succesfully identified with server") + @identified = true when Mixin::OPCodes::EVENT, Mixin::OPCodes::REQUESTRESPONSE changed - notify_observers(op_code, data[:d]) + notify_observers(data[:op], data[:d]) end end From 64539291a17ef9fa81240f9d8227022c236c7181 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Sun, 23 Oct 2022 23:33:48 +0100 Subject: [PATCH 2/2] patch bump --- lib/obsws/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/obsws/version.rb b/lib/obsws/version.rb index 2f6b3e9..ea02682 100644 --- a/lib/obsws/version.rb +++ b/lib/obsws/version.rb @@ -11,7 +11,7 @@ module OBSWS end def patch - 2 + 3 end def to_a