obsws 0.2.1 → 0.3.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 +4 -7
- data/lib/obsws/base.rb +6 -5
- data/lib/obsws/event.rb +4 -1
- data/lib/obsws/logger.rb +11 -0
- data/lib/obsws/req.rb +5 -2
- data/lib/obsws/util.rb +2 -3
- data/lib/obsws/version.rb +2 -2
- data/lib/obsws.rb +0 -6
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f55dbfe2267a8b2dec6fc0c347b537b1a9727de641ec762d16128a40ee3397a4
|
4
|
+
data.tar.gz: 3ef38f6bfb12db426c31afdb130e25debda7173e135daf9d88677d6002365c55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2914cfd19dd1107ecd0d8825ca5386b9e6574983527098801fed5f0ed3c06520490f139d9c3837d45aa2791cd8e20e263b07ada46d46d7957a399aebd629ad2
|
7
|
+
data.tar.gz: 1d76544ea453fc16bad1d38b64ff4328ad1665520323112694007377e75959ce78f05027cfb85ef176b74148374f15c60b03b627f92552e6741171919f930c37
|
data/README.md
CHANGED
@@ -114,15 +114,12 @@ For a full list of status codes refer to [Codes](https://github.com/obsproject/o
|
|
114
114
|
|
115
115
|
### Logging
|
116
116
|
|
117
|
-
To
|
117
|
+
To enable logs set an environmental variable `OBSWS_LOG_LEVEL` to the appropriate level.
|
118
118
|
|
119
|
-
example:
|
120
|
-
|
121
|
-
```ruby
|
122
|
-
require "obsws"
|
119
|
+
example in powershell:
|
123
120
|
|
124
|
-
|
125
|
-
|
121
|
+
```powershell
|
122
|
+
$env:OBSWS_LOG_LEVEL="DEBUG"
|
126
123
|
```
|
127
124
|
|
128
125
|
### Tests
|
data/lib/obsws/base.rb
CHANGED
@@ -6,6 +6,7 @@ require "waitutil"
|
|
6
6
|
|
7
7
|
require_relative "mixin"
|
8
8
|
require_relative "error"
|
9
|
+
require_relative "logger"
|
9
10
|
|
10
11
|
module OBSWS
|
11
12
|
class Socket
|
@@ -22,6 +23,7 @@ module OBSWS
|
|
22
23
|
end
|
23
24
|
|
24
25
|
class Base
|
26
|
+
include Logging
|
25
27
|
include Mixin::OPCodes
|
26
28
|
|
27
29
|
attr_reader :closed
|
@@ -37,14 +39,13 @@ module OBSWS
|
|
37
39
|
@driver =
|
38
40
|
WebSocket::Driver.client(Socket.new("ws://#{host}:#{port}", @socket))
|
39
41
|
@driver.on :open do |msg|
|
40
|
-
|
42
|
+
logger.debug("driver socket open")
|
41
43
|
end
|
42
44
|
@driver.on :close do |msg|
|
43
|
-
|
45
|
+
logger.debug("driver socket closed")
|
44
46
|
@closed = true
|
45
47
|
end
|
46
48
|
@driver.on :message do |msg|
|
47
|
-
LOGGER.debug("received: #{msg.data}")
|
48
49
|
msg_handler(JSON.parse(msg.data, symbolize_names: true))
|
49
50
|
end
|
50
51
|
start_driver
|
@@ -91,7 +92,7 @@ module OBSWS
|
|
91
92
|
if @password.empty?
|
92
93
|
raise OBSWSError("auth enabled but no password provided")
|
93
94
|
end
|
94
|
-
|
95
|
+
logger.info("initiating authentication")
|
95
96
|
payload[:d][:authentication] = auth_token(**auth)
|
96
97
|
end
|
97
98
|
@driver.text(JSON.generate(payload))
|
@@ -117,7 +118,7 @@ module OBSWS
|
|
117
118
|
}
|
118
119
|
}
|
119
120
|
payload[:d][:requestData] = data if data
|
120
|
-
|
121
|
+
logger.debug("sending request: #{payload}")
|
121
122
|
@driver.text(JSON.generate(payload))
|
122
123
|
end
|
123
124
|
end
|
data/lib/obsws/event.rb
CHANGED
@@ -2,6 +2,7 @@ require "json"
|
|
2
2
|
|
3
3
|
require_relative "util"
|
4
4
|
require_relative "mixin"
|
5
|
+
require_relative "logger"
|
5
6
|
|
6
7
|
module OBSWS
|
7
8
|
module Events
|
@@ -62,6 +63,7 @@ module OBSWS
|
|
62
63
|
end
|
63
64
|
|
64
65
|
class Client
|
66
|
+
include Logging
|
65
67
|
include Callbacks
|
66
68
|
include Mixin::TearDown
|
67
69
|
include Mixin::OPCodes
|
@@ -69,9 +71,10 @@ module OBSWS
|
|
69
71
|
def initialize(**kwargs)
|
70
72
|
kwargs[:subs] ||= SUBS::LOW_VOLUME
|
71
73
|
@base_client = Base.new(**kwargs)
|
72
|
-
|
74
|
+
logger.info("#{self} succesfully identified with server")
|
73
75
|
@base_client.updater = ->(op_code, data) {
|
74
76
|
if op_code == Mixin::OPCodes::EVENT
|
77
|
+
logger.debug("received: #{data}")
|
75
78
|
event = data[:eventType]
|
76
79
|
data = data.fetch(:eventData, {})
|
77
80
|
notify_observers(event, Mixin::Data.new(data, data.keys))
|
data/lib/obsws/logger.rb
ADDED
data/lib/obsws/req.rb
CHANGED
@@ -4,18 +4,21 @@ require_relative "base"
|
|
4
4
|
require_relative "error"
|
5
5
|
require_relative "util"
|
6
6
|
require_relative "mixin"
|
7
|
+
require_relative "logger"
|
7
8
|
|
8
9
|
module OBSWS
|
9
10
|
module Requests
|
10
11
|
class Client
|
12
|
+
include Logging
|
11
13
|
include Error
|
12
14
|
include Mixin::TearDown
|
13
15
|
include Mixin::OPCodes
|
14
16
|
|
15
17
|
def initialize(**kwargs)
|
16
18
|
@base_client = Base.new(**kwargs)
|
17
|
-
|
19
|
+
logger.info("#{self} succesfully identified with server")
|
18
20
|
@base_client.updater = ->(op_code, data) {
|
21
|
+
logger.debug("response received: #{data}")
|
19
22
|
@response = data if op_code == Mixin::OPCodes::REQUESTRESPONSE
|
20
23
|
}
|
21
24
|
@response = {requestId: 0}
|
@@ -56,7 +59,7 @@ module OBSWS
|
|
56
59
|
@response[:responseData]
|
57
60
|
rescue WaitUtil::TimeoutError
|
58
61
|
msg = "no response with matching id received"
|
59
|
-
|
62
|
+
logger.error(msg)
|
60
63
|
raise OBSWSError.new(msg)
|
61
64
|
end
|
62
65
|
|
data/lib/obsws/util.rb
CHANGED
@@ -2,12 +2,11 @@ module OBSWS
|
|
2
2
|
module Util
|
3
3
|
class ::String
|
4
4
|
def to_camel
|
5
|
-
|
5
|
+
split("_").map(&:capitalize).join
|
6
6
|
end
|
7
7
|
|
8
8
|
def to_snake
|
9
|
-
|
10
|
-
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
9
|
+
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
11
10
|
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
12
11
|
.downcase
|
13
12
|
end
|
data/lib/obsws/version.rb
CHANGED
data/lib/obsws.rb
CHANGED
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- onyx_online
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/obsws/base.rb
|
109
109
|
- lib/obsws/error.rb
|
110
110
|
- lib/obsws/event.rb
|
111
|
+
- lib/obsws/logger.rb
|
111
112
|
- lib/obsws/mixin.rb
|
112
113
|
- lib/obsws/req.rb
|
113
114
|
- lib/obsws/util.rb
|