mirror of
https://github.com/onyx-and-iris/obsws-ruby.git
synced 2025-01-18 05:20:47 +00:00
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:
parent
9842bed8b6
commit
b33fe94cee
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user