obsws 0.4.2 → 0.5.0
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 -1
- data/lib/obsws/base.rb +0 -9
- data/lib/obsws/driver.rb +0 -3
- data/lib/obsws/event.rb +5 -6
- data/lib/obsws/logger.rb +0 -2
- data/lib/obsws/mixin.rb +0 -2
- data/lib/obsws/req.rb +20 -20
- data/lib/obsws/version.rb +3 -5
- data/lib/obsws.rb +37 -0
- metadata +2 -3
- data/lib/obsws/error.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7826cef2f98842479438cf09ac7dec77e7c8e24a8adca3dcf55fce92676c2f4
|
4
|
+
data.tar.gz: 0c5dc416a213a344488cf2059d789aa07536d83440b14fd9c2d41918821e5a9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 178671ff1a8f5577694fe4d7f02e0c96f6d37ef50ec36ba6ee802f6999ad5fc470695ade79caf2393b32eb9d0fc325236131490f5348a020d9fb73eb6aaa219d
|
7
|
+
data.tar.gz: bb0fe9a35b56699bd64b0f0d55d1f203ceaa7fe1abfafcc5d3ca23cb3207275662f223a1d4a124e1a89f52c724d688fdfaf5f548bec5586155ee732d99bebb08
|
data/README.md
CHANGED
@@ -109,7 +109,13 @@ def on_scene_created(data):
|
|
109
109
|
|
110
110
|
### Errors
|
111
111
|
|
112
|
-
If a
|
112
|
+
If a general error occurs an `OBSWSError` will be raised.
|
113
|
+
|
114
|
+
If a connection attempt fails or times out an `OBSWSConnectionError` will be raised.
|
115
|
+
|
116
|
+
If a request fails an `OBSWSRequestError` will be raised with a status code.
|
117
|
+
|
118
|
+
- The request name and code are retrievable through attributes {OBSWSRequestError}.name and {OBSWSRequestError}.code
|
113
119
|
|
114
120
|
For a full list of status codes refer to [Codes](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requeststatus)
|
115
121
|
|
data/lib/obsws/base.rb
CHANGED
data/lib/obsws/driver.rb
CHANGED
data/lib/obsws/event.rb
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
require "json"
|
2
|
-
|
3
|
-
require_relative "util"
|
4
|
-
require_relative "mixin"
|
5
|
-
require_relative "logger"
|
6
|
-
|
7
1
|
module OBSWS
|
8
2
|
module Events
|
9
3
|
module SUBS
|
@@ -78,6 +72,11 @@ module OBSWS
|
|
78
72
|
kwargs[:subs] ||= SUBS::LOW_VOLUME
|
79
73
|
@base_client = Base.new(**kwargs)
|
80
74
|
logger.info("#{self} successfully identified with server")
|
75
|
+
rescue Errno::ECONNREFUSED, WaitUtil::TimeoutError => e
|
76
|
+
msg = "#{e.class.name}: #{e.message}"
|
77
|
+
logger.error(msg)
|
78
|
+
raise OBSWSConnectionError.new(msg)
|
79
|
+
else
|
81
80
|
@base_client.updater = ->(op_code, data) {
|
82
81
|
if op_code == Mixin::OPCodes::EVENT
|
83
82
|
logger.debug("received: #{data}")
|
data/lib/obsws/logger.rb
CHANGED
data/lib/obsws/mixin.rb
CHANGED
data/lib/obsws/req.rb
CHANGED
@@ -1,22 +1,18 @@
|
|
1
|
-
require "waitutil"
|
2
|
-
|
3
|
-
require_relative "base"
|
4
|
-
require_relative "error"
|
5
|
-
require_relative "util"
|
6
|
-
require_relative "mixin"
|
7
|
-
require_relative "logger"
|
8
|
-
|
9
1
|
module OBSWS
|
10
2
|
module Requests
|
11
3
|
class Client
|
12
4
|
include Logging
|
13
|
-
include Error
|
14
5
|
include Mixin::TearDown
|
15
6
|
include Mixin::OPCodes
|
16
7
|
|
17
8
|
def initialize(**kwargs)
|
18
9
|
@base_client = Base.new(**kwargs)
|
19
10
|
logger.info("#{self} successfully identified with server")
|
11
|
+
rescue Errno::ECONNREFUSED, WaitUtil::TimeoutError => e
|
12
|
+
msg = "#{e.class.name}: #{e.message}"
|
13
|
+
logger.error(msg)
|
14
|
+
raise OBSWSConnectionError.new(msg)
|
15
|
+
else
|
20
16
|
@base_client.updater = ->(op_code, data) {
|
21
17
|
logger.debug("response received: #{data}")
|
22
18
|
@response = data if op_code == Mixin::OPCodes::REQUESTRESPONSE
|
@@ -48,19 +44,23 @@ module OBSWS
|
|
48
44
|
timeout_sec: 3
|
49
45
|
) { @response[:requestId] == id }
|
50
46
|
unless @response[:requestStatus][:result]
|
51
|
-
|
52
|
-
"Request #{@response[:requestType]} returned code #{@response[:requestStatus][:code]}"
|
53
|
-
]
|
54
|
-
if @response[:requestStatus].key?(:comment)
|
55
|
-
error << ["With message: #{@response[:requestStatus][:comment]}"]
|
56
|
-
end
|
57
|
-
raise OBSWSError.new(error.join("\n"))
|
47
|
+
raise OBSWSRequestError.new(@response[:requestType], @response[:requestStatus][:code], @response[:requestStatus][:comment])
|
58
48
|
end
|
59
49
|
@response[:responseData]
|
60
|
-
rescue
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
+
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)
|
64
64
|
end
|
65
65
|
|
66
66
|
def get_version
|
data/lib/obsws/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module OBSWS
|
2
|
-
module
|
2
|
+
module VERSION
|
3
3
|
module_function
|
4
4
|
|
5
5
|
def major
|
@@ -7,11 +7,11 @@ module OBSWS
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def minor
|
10
|
-
|
10
|
+
5
|
11
11
|
end
|
12
12
|
|
13
13
|
def patch
|
14
|
-
|
14
|
+
0
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_a
|
@@ -22,6 +22,4 @@ module OBSWS
|
|
22
22
|
to_a.join(".")
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
26
|
-
VERSION = Version.to_s
|
27
25
|
end
|
data/lib/obsws.rb
CHANGED
@@ -1,5 +1,42 @@
|
|
1
|
+
require "digest/sha2"
|
2
|
+
require "json"
|
3
|
+
require "waitutil"
|
4
|
+
require "socket"
|
5
|
+
require "websocket/driver"
|
6
|
+
require "logger"
|
7
|
+
|
8
|
+
require_relative "obsws/logger"
|
9
|
+
require_relative "obsws/driver"
|
10
|
+
require_relative "obsws/util"
|
11
|
+
require_relative "obsws/mixin"
|
12
|
+
require_relative "obsws/base"
|
13
|
+
|
1
14
|
require_relative "obsws/req"
|
2
15
|
require_relative "obsws/event"
|
3
16
|
|
17
|
+
require_relative "obsws/version"
|
18
|
+
|
4
19
|
module OBSWS
|
20
|
+
class OBSWSError < StandardError; end
|
21
|
+
|
22
|
+
class OBSWSConnectionError < OBSWSError; end
|
23
|
+
|
24
|
+
class OBSWSRequestError < OBSWSError
|
25
|
+
attr_reader :name, :code
|
26
|
+
|
27
|
+
def initialize(name, code, msg)
|
28
|
+
@name = name
|
29
|
+
@code = code
|
30
|
+
@msg = msg
|
31
|
+
super(message)
|
32
|
+
end
|
33
|
+
|
34
|
+
def message
|
35
|
+
msg = [
|
36
|
+
"Request #{@name} returned code #{@code}."
|
37
|
+
]
|
38
|
+
msg << "With message: #{@msg}" if @msg
|
39
|
+
msg.join(" ")
|
40
|
+
end
|
41
|
+
end
|
5
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obsws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- onyx_online
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket-driver
|
@@ -107,7 +107,6 @@ files:
|
|
107
107
|
- lib/obsws.rb
|
108
108
|
- lib/obsws/base.rb
|
109
109
|
- lib/obsws/driver.rb
|
110
|
-
- lib/obsws/error.rb
|
111
110
|
- lib/obsws/event.rb
|
112
111
|
- lib/obsws/logger.rb
|
113
112
|
- lib/obsws/mixin.rb
|