moved logger auth success to req,event classes

override to_s for req,event classes

rename authenticate to identify in base class
This commit is contained in:
onyx-and-iris 2022-10-25 00:03:43 +01:00
parent 9842bed8b6
commit b33fe94cee
3 changed files with 13 additions and 8 deletions

View File

@ -74,7 +74,8 @@ module OBSWS
) )
end end
def authenticate(auth = nil) def identify(auth)
LOGGER.info("initiating authentication") if auth
payload = { payload = {
op: Mixin::OPCodes::IDENTIFY, op: Mixin::OPCodes::IDENTIFY,
d: { d: {
@ -89,14 +90,8 @@ module OBSWS
def msg_handler(data) def msg_handler(data)
case data[:op] case data[:op]
when Mixin::OPCodes::HELLO when Mixin::OPCodes::HELLO
if data[:d].key? :authentication identify(data[:d][:authentication])
LOGGER.debug("initiating authentication")
else
LOGGER.debug("authentication disabled... skipping.")
end
authenticate(data[:d][:authentication])
when Mixin::OPCodes::IDENTIFIED when Mixin::OPCodes::IDENTIFIED
LOGGER.debug("client succesfully identified with server")
@identified = true @identified = true
when Mixin::OPCodes::EVENT, Mixin::OPCodes::REQUESTRESPONSE when Mixin::OPCodes::EVENT, Mixin::OPCodes::REQUESTRESPONSE
changed changed

View File

@ -77,9 +77,14 @@ module OBSWS
def initialize(**kwargs) def initialize(**kwargs)
kwargs[:subs] = SUBS.low_volume kwargs[:subs] = SUBS.low_volume
@base_client = Base.new(**kwargs) @base_client = Base.new(**kwargs)
LOGGER.info("#{self} succesfully identified with server")
@base_client.add_observer(self) @base_client.add_observer(self)
end end
def to_s
"#{self.class.name.split("::").last(2).join("::")}"
end
def update(op_code, data) def update(op_code, data)
if op_code == Mixin::OPCodes::EVENT if op_code == Mixin::OPCodes::EVENT
event = data[:eventType] event = data[:eventType]

View File

@ -14,10 +14,15 @@ module OBSWS
def initialize(**kwargs) def initialize(**kwargs)
@base_client = Base.new(**kwargs) @base_client = Base.new(**kwargs)
LOGGER.info("#{self} succesfully identified with server")
@base_client.add_observer(self) @base_client.add_observer(self)
@response = { requestId: 0 } @response = { requestId: 0 }
end end
def to_s
"#{self.class.name.split("::").last(2).join("::")}"
end
def run def run
yield yield
ensure ensure