obsws 0.5.2 → 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: 516727ae86bc3f1f6eaa13a6bc4434bbed7fdeaebd1d5311ba52b40de1a292f0
4
- data.tar.gz: 1d42563cfd5d224a1e0f6bad9cbc306222105b098cedb46a062b20544d409104
3
+ metadata.gz: 0e1082183fb2605b7ca64747dcd88930516b4132b02f142afa7bb6db58e62120
4
+ data.tar.gz: 752365a78828d329a6d765a8920398efdf09a426122cc0e7b0380c8db27f9d5a
5
5
  SHA512:
6
- metadata.gz: a320d897a324f6f90c7fca50f27dee4f3fcf62121e14c2787f144e8b90a3a1e7732b82e6a54571b427bc61dd0eb43cde47da8ff5e3dd31068dc25468063055fe
7
- data.tar.gz: '08886350eb47e6689d60dd5afe6dffe0bb69709f6b3b2ad95cd2b98a85c5e3f2948cfdcc7cb63582f710afcaaa1bb9a24980f4091460f8e76bbd37507fa196a6'
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
- 2
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"
@@ -33,7 +34,7 @@ module OBSWS
33
34
 
34
35
  def message
35
36
  msg = [
36
- "Request #{@name} returned code #{@code}."
37
+ "Request #{@req_name} returned code #{@code}."
37
38
  ]
38
39
  msg << "With message: #{@msg}" if @msg
39
40
  msg.join(" ")
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.2
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - onyx_online