From b33fe94cee51b1de46168ee0357b3c686a730249 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Tue, 25 Oct 2022 00:03:43 +0100 Subject: [PATCH] moved logger auth success to req,event classes override to_s for req,event classes rename authenticate to identify in base class --- lib/obsws/base.rb | 11 +++-------- lib/obsws/event.rb | 5 +++++ lib/obsws/req.rb | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/obsws/base.rb b/lib/obsws/base.rb index 6f711b1..504713b 100644 --- a/lib/obsws/base.rb +++ b/lib/obsws/base.rb @@ -74,7 +74,8 @@ module OBSWS ) end - def authenticate(auth = nil) + def identify(auth) + LOGGER.info("initiating authentication") if auth payload = { op: Mixin::OPCodes::IDENTIFY, d: { @@ -89,14 +90,8 @@ module OBSWS def msg_handler(data) case data[:op] when Mixin::OPCodes::HELLO - if data[:d].key? :authentication - LOGGER.debug("initiating authentication") - else - LOGGER.debug("authentication disabled... skipping.") - end - authenticate(data[:d][:authentication]) + identify(data[:d][:authentication]) when Mixin::OPCodes::IDENTIFIED - LOGGER.debug("client succesfully identified with server") @identified = true when Mixin::OPCodes::EVENT, Mixin::OPCodes::REQUESTRESPONSE changed diff --git a/lib/obsws/event.rb b/lib/obsws/event.rb index 879fa2c..32e8385 100644 --- a/lib/obsws/event.rb +++ b/lib/obsws/event.rb @@ -77,9 +77,14 @@ module OBSWS def initialize(**kwargs) kwargs[:subs] = SUBS.low_volume @base_client = Base.new(**kwargs) + LOGGER.info("#{self} succesfully identified with server") @base_client.add_observer(self) end + def to_s + "#{self.class.name.split("::").last(2).join("::")}" + end + def update(op_code, data) if op_code == Mixin::OPCodes::EVENT event = data[:eventType] diff --git a/lib/obsws/req.rb b/lib/obsws/req.rb index 4ad1c4c..f5454d9 100644 --- a/lib/obsws/req.rb +++ b/lib/obsws/req.rb @@ -14,10 +14,15 @@ module OBSWS def initialize(**kwargs) @base_client = Base.new(**kwargs) + LOGGER.info("#{self} succesfully identified with server") @base_client.add_observer(self) @response = { requestId: 0 } end + def to_s + "#{self.class.name.split("::").last(2).join("::")}" + end + def run yield ensure