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