mirror of
https://github.com/onyx-and-iris/obsws-ruby.git
synced 2024-11-15 18:50: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 "digest/sha2"
|
||||||
require "json"
|
require "json"
|
||||||
require "waitutil"
|
|
||||||
require "socket"
|
|
||||||
require "websocket/driver"
|
|
||||||
require "logger"
|
require "logger"
|
||||||
|
require "securerandom"
|
||||||
|
require "socket"
|
||||||
|
require "waitutil"
|
||||||
|
require "websocket/driver"
|
||||||
|
|
||||||
require_relative "obsws/logger"
|
require_relative "obsws/logger"
|
||||||
require_relative "obsws/driver"
|
require_relative "obsws/driver"
|
||||||
|
@ -35,20 +35,19 @@ module OBSWS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def call(req, data = nil)
|
def call(req, data = nil)
|
||||||
id = rand(1..1000)
|
uuid = SecureRandom.uuid
|
||||||
@base_client.req(id, req, data)
|
@base_client.req(uuid, req, data)
|
||||||
WaitUtil.wait_for_condition(
|
WaitUtil.wait_for_condition(
|
||||||
"reponse id to match request id",
|
"reponse id to match request id",
|
||||||
delay_sec: 0.001,
|
delay_sec: 0.001,
|
||||||
timeout_sec: 3
|
timeout_sec: 3
|
||||||
) { @response[:requestId] == id }
|
) { @response[:requestId] == uuid }
|
||||||
unless @response[:requestStatus][:result]
|
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
|
end
|
||||||
@response[:responseData]
|
@response[:responseData]
|
||||||
rescue OBSWSRequestError => e
|
|
||||||
logger.error(["#{e.class.name}: #{e.message}", *e.backtrace].join("\n"))
|
|
||||||
raise
|
|
||||||
rescue WaitUtil::TimeoutError => e
|
rescue WaitUtil::TimeoutError => e
|
||||||
logger.error(["#{e.class.name}: #{e.message}", *e.backtrace].join("\n"))
|
logger.error(["#{e.class.name}: #{e.message}", *e.backtrace].join("\n"))
|
||||||
raise OBSWSError.new([e.message, *e.backtrace].join("\n"))
|
raise OBSWSError.new([e.message, *e.backtrace].join("\n"))
|
||||||
|
Loading…
Reference in New Issue
Block a user