obsws 0.5.3 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/lib/obsws/base.rb +1 -1
- data/lib/obsws/req.rb +10 -20
- data/lib/obsws/version.rb +1 -1
- data/lib/obsws.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e1082183fb2605b7ca64747dcd88930516b4132b02f142afa7bb6db58e62120
|
4
|
+
data.tar.gz: 752365a78828d329a6d765a8920398efdf09a426122cc0e7b0380c8db27f9d5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 812133a0bf0019e5cf59c6bcae577c256b862bc497df97f2f1265e88b0c6616277b2afa44f376ae932137b2baac499cca0acf4dbf5d139e15baac268fc629818
|
7
|
+
data.tar.gz: a7ff0fe86ac3d988beee0d6ff2d31fd3b8e235b189afe9265e65d190bbb10953e85e7106578190fd4ece5e4e171d13ecf0aeefb16bd16d719ac203da62449799
|
data/README.md
CHANGED
@@ -30,13 +30,17 @@ Pass `host`, `port` and `password` as keyword arguments.
|
|
30
30
|
require "obsws"
|
31
31
|
|
32
32
|
class Main
|
33
|
+
INPUT = "Mic/Aux"
|
34
|
+
|
33
35
|
def run
|
34
36
|
OBSWS::Requests::Client
|
35
37
|
.new(host: "localhost", port: 4455, password: "strongpassword")
|
36
38
|
.run do |client|
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
# Toggle the mute state of your Mic input and print its new mute state
|
40
|
+
client.toggle_input_mute(INPUT)
|
41
|
+
resp = client.get_input_mute(INPUT)
|
42
|
+
puts "Input '#{INPUT}' was set to #{resp.input_muted}"
|
43
|
+
end
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
data/lib/obsws/base.rb
CHANGED
data/lib/obsws/req.rb
CHANGED
@@ -9,9 +9,8 @@ module OBSWS
|
|
9
9
|
@base_client = Base.new(**kwargs)
|
10
10
|
logger.info("#{self} successfully identified with server")
|
11
11
|
rescue Errno::ECONNREFUSED, WaitUtil::TimeoutError => e
|
12
|
-
|
13
|
-
|
14
|
-
raise OBSWSConnectionError.new(msg)
|
12
|
+
logger.error("#{e.class.name}: #{e.message}")
|
13
|
+
raise OBSWSConnectionError.new(e.message)
|
15
14
|
else
|
16
15
|
@base_client.updater = ->(op_code, data) {
|
17
16
|
logger.debug("response received: #{data}")
|
@@ -36,31 +35,22 @@ module OBSWS
|
|
36
35
|
end
|
37
36
|
|
38
37
|
def call(req, data = nil)
|
39
|
-
|
40
|
-
@base_client.req(
|
38
|
+
uuid = SecureRandom.uuid
|
39
|
+
@base_client.req(uuid, req, data)
|
41
40
|
WaitUtil.wait_for_condition(
|
42
41
|
"reponse id to match request id",
|
43
42
|
delay_sec: 0.001,
|
44
43
|
timeout_sec: 3
|
45
|
-
) { @response[:requestId] ==
|
44
|
+
) { @response[:requestId] == uuid }
|
46
45
|
unless @response[:requestStatus][:result]
|
47
|
-
|
46
|
+
OBSWSRequestError.new(@response[:requestType], @response[:requestStatus][:code], @response[:requestStatus][:comment]) => e
|
47
|
+
logger.error(["#{e.class.name}: #{e.message}", *e.backtrace].join("\n"))
|
48
|
+
raise e
|
48
49
|
end
|
49
50
|
@response[:responseData]
|
50
|
-
rescue OBSWSRequestError => e
|
51
|
-
err_msg = [
|
52
|
-
"#{e.class.name}: #{e.message}",
|
53
|
-
*e.backtrace
|
54
|
-
]
|
55
|
-
logger.error(err_msg.join("\n"))
|
56
|
-
raise
|
57
51
|
rescue WaitUtil::TimeoutError => e
|
58
|
-
|
59
|
-
|
60
|
-
*e.backtrace
|
61
|
-
]
|
62
|
-
logger.error(err_msg)
|
63
|
-
raise OBSWSError.new(err_msg)
|
52
|
+
logger.error(["#{e.class.name}: #{e.message}", *e.backtrace].join("\n"))
|
53
|
+
raise OBSWSError.new([e.message, *e.backtrace].join("\n"))
|
64
54
|
end
|
65
55
|
|
66
56
|
def get_version
|
data/lib/obsws/version.rb
CHANGED
data/lib/obsws.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "digest/sha2"
|
2
2
|
require "json"
|
3
|
-
require "
|
3
|
+
require "logger"
|
4
|
+
require "securerandom"
|
4
5
|
require "socket"
|
6
|
+
require "waitutil"
|
5
7
|
require "websocket/driver"
|
6
|
-
require "logger"
|
7
8
|
|
8
9
|
require_relative "obsws/logger"
|
9
10
|
require_relative "obsws/driver"
|