mirror of
https://github.com/onyx-and-iris/obsws-ruby.git
synced 2025-01-18 05:20:47 +00:00
request ids are now UUID's.
This commit is contained in:
parent
c6bb8d07ff
commit
3ef4396885
@ -1,9 +1,10 @@
|
||||
require "digest/sha2"
|
||||
require "json"
|
||||
require "waitutil"
|
||||
require "socket"
|
||||
require "websocket/driver"
|
||||
require "logger"
|
||||
require "securerandom"
|
||||
require "socket"
|
||||
require "waitutil"
|
||||
require "websocket/driver"
|
||||
|
||||
require_relative "obsws/logger"
|
||||
require_relative "obsws/driver"
|
||||
|
@ -35,20 +35,19 @@ module OBSWS
|
||||
end
|
||||
|
||||
def call(req, data = nil)
|
||||
id = rand(1..1000)
|
||||
@base_client.req(id, req, data)
|
||||
uuid = SecureRandom.uuid
|
||||
@base_client.req(uuid, req, data)
|
||||
WaitUtil.wait_for_condition(
|
||||
"reponse id to match request id",
|
||||
delay_sec: 0.001,
|
||||
timeout_sec: 3
|
||||
) { @response[:requestId] == id }
|
||||
) { @response[:requestId] == uuid }
|
||||
unless @response[:requestStatus][:result]
|
||||
raise OBSWSRequestError.new(@response[:requestType], @response[:requestStatus][:code], @response[:requestStatus][:comment])
|
||||
OBSWSRequestError.new(@response[:requestType], @response[:requestStatus][:code], @response[:requestStatus][:comment]) => e
|
||||
logger.error(["#{e.class.name}: #{e.message}", *e.backtrace].join("\n"))
|
||||
raise e
|
||||
end
|
||||
@response[:responseData]
|
||||
rescue OBSWSRequestError => e
|
||||
logger.error(["#{e.class.name}: #{e.message}", *e.backtrace].join("\n"))
|
||||
raise
|
||||
rescue WaitUtil::TimeoutError => e
|
||||
logger.error(["#{e.class.name}: #{e.message}", *e.backtrace].join("\n"))
|
||||
raise OBSWSError.new([e.message, *e.backtrace].join("\n"))
|
||||
|
Loading…
Reference in New Issue
Block a user