mirror of
https://github.com/onyx-and-iris/obsws-ruby.git
synced 2024-11-15 18:50:47 +00:00
Merge branch 'main' into dev
This commit is contained in:
commit
2ed1368dcb
@ -50,10 +50,10 @@ module OBSWS
|
|||||||
end
|
end
|
||||||
start_driver
|
start_driver
|
||||||
WaitUtil.wait_for_condition(
|
WaitUtil.wait_for_condition(
|
||||||
"waiting authentication successful",
|
"waiting successful identification",
|
||||||
delay_sec: 0.01,
|
delay_sec: 0.01,
|
||||||
timeout_sec: 3
|
timeout_sec: 3
|
||||||
) { @authenticated }
|
) { @identified }
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_driver
|
def start_driver
|
||||||
@ -74,32 +74,33 @@ module OBSWS
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate(auth)
|
def authenticate(auth = nil)
|
||||||
token = auth_token(**auth)
|
|
||||||
payload = {
|
payload = {
|
||||||
op: Mixin::OPCodes::IDENTIFY,
|
op: Mixin::OPCodes::IDENTIFY,
|
||||||
d: {
|
d: {
|
||||||
rpcVersion: 1,
|
rpcVersion: 1,
|
||||||
authentication: token,
|
|
||||||
eventSubscriptions: @subs
|
eventSubscriptions: @subs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOGGER.debug("initiating authentication")
|
payload[:d][:authentication] = auth_token(**auth) if auth
|
||||||
@driver.text(JSON.generate(payload))
|
@driver.text(JSON.generate(payload))
|
||||||
end
|
end
|
||||||
|
|
||||||
def msg_handler(data)
|
def msg_handler(data)
|
||||||
op_code = data[:op]
|
case data[:op]
|
||||||
case op_code
|
|
||||||
when Mixin::OPCodes::HELLO
|
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])
|
authenticate(data[:d][:authentication])
|
||||||
when Mixin::OPCodes::IDENTIFIED
|
when Mixin::OPCodes::IDENTIFIED
|
||||||
LOGGER.debug("authentication successful")
|
LOGGER.debug("client succesfully identified with server")
|
||||||
@authenticated = true
|
@identified = true
|
||||||
when Mixin::OPCodes::EVENT, Mixin::OPCodes::REQUESTRESPONSE
|
when Mixin::OPCodes::EVENT, Mixin::OPCodes::REQUESTRESPONSE
|
||||||
changed
|
changed
|
||||||
notify_observers(op_code, data[:d])
|
notify_observers(data[:op], data[:d])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ module OBSWS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def patch
|
def patch
|
||||||
2
|
3
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_a
|
def to_a
|
||||||
|
Loading…
Reference in New Issue
Block a user