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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4aeda40922d842790c7aa969608fe100ad4bd1b9dfc34ba586ec4d126c64abca
4
- data.tar.gz: f2a6f162110e7bd46eaec6a5aa5fd1b30c684a8d0b4e1ab6e68b9e127ba1994f
3
+ metadata.gz: 0e1082183fb2605b7ca64747dcd88930516b4132b02f142afa7bb6db58e62120
4
+ data.tar.gz: 752365a78828d329a6d765a8920398efdf09a426122cc0e7b0380c8db27f9d5a
5
5
  SHA512:
6
- metadata.gz: '065915f3edb1d8e0235ce88765fe2dde21e300f905d20d569e7cd630db8446a281be695ee8059449f77f8d224eecab4ad445ad379362e5032e5fe36a1d1e675b'
7
- data.tar.gz: 562b42f5b9b0152ffe22ba3b5dda1d4553c8f09be645709e589a2cc2d0e245a091396fc6c0bc83eb0a63cb10467f10e42cb25856767ee33dbd478e8d52dc9bb1
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
- # Toggle the mute state of your Mic input
38
- client.toggle_input_mute("Mic/Aux")
39
- end
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
@@ -16,7 +16,7 @@ module OBSWS
16
16
  WaitUtil.wait_for_condition(
17
17
  "successful identification",
18
18
  delay_sec: 0.01,
19
- timeout_sec: 3
19
+ timeout_sec: kwargs[:connect_timeout] || 3
20
20
  ) { @identified }
21
21
  end
22
22
 
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
- msg = "#{e.class.name}: #{e.message}"
13
- logger.error(msg)
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
- id = rand(1..1000)
40
- @base_client.req(id, req, data)
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] == id }
44
+ ) { @response[:requestId] == uuid }
46
45
  unless @response[:requestStatus][:result]
47
- raise OBSWSRequestError.new(@response[:requestType], @response[:requestStatus][:code], @response[:requestStatus][:comment])
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
- err_msg = [
59
- "#{e.class.name}: #{e.message}",
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
@@ -11,7 +11,7 @@ module OBSWS
11
11
  end
12
12
 
13
13
  def patch
14
- 3
14
+ 6
15
15
  end
16
16
 
17
17
  def to_a
data/lib/obsws.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require "digest/sha2"
2
2
  require "json"
3
- require "waitutil"
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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obsws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - onyx_online