obsws 0.3.3 → 0.4.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 +12 -11
- data/lib/obsws/event.rb +9 -6
- data/lib/obsws/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c275787361111b1b84f2f5023d5d24e45b174540a8e687aaaae2fa647b89eecc
|
4
|
+
data.tar.gz: 738122bc2be93730ef117240c467ec261ab6918c406dea273eefc134d5f74362
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 121d5bf831969d5bd92244efb4c6ae94fdea7e6a47b16c9b7bbee80626e6739664433bb04e3225aef2eaa759127ee074841e05b430331c3bd987762c8623f15c
|
7
|
+
data.tar.gz: e67e598037d689469263721e2408eacebd6469e32a5b55e50f43876efe33d5b3b581e99ec2d804ed28549079f6b4855c76e8508e65e46d504bca12e75e32fff9
|
data/README.md
CHANGED
@@ -16,14 +16,10 @@
|
|
16
16
|
### Bundler
|
17
17
|
|
18
18
|
```
|
19
|
-
bundle add
|
19
|
+
bundle add obsws
|
20
20
|
bundle install
|
21
21
|
```
|
22
22
|
|
23
|
-
### Gem
|
24
|
-
|
25
|
-
`gem install 'obsws'`
|
26
|
-
|
27
23
|
## `Use`
|
28
24
|
|
29
25
|
#### Example `main.rb`
|
@@ -67,23 +63,28 @@ For a full list of requests refer to [Requests](https://github.com/obsproject/ob
|
|
67
63
|
|
68
64
|
### Events
|
69
65
|
|
70
|
-
Register
|
66
|
+
Register `on_` callback methods. Method names should match the api event but snake cased.
|
71
67
|
|
72
68
|
example:
|
73
69
|
|
74
70
|
```ruby
|
75
71
|
class Observer
|
76
72
|
def initialize
|
77
|
-
@e_client = OBSWS::Events::Client.new(
|
78
|
-
# register
|
79
|
-
@e_client.
|
73
|
+
@e_client = OBSWS::Events::Client.new(host: "localhost", port: 4455, password: "strongpassword")
|
74
|
+
# register callback methods with the Event client
|
75
|
+
@e_client.register(
|
76
|
+
[
|
77
|
+
method(:on_current_program_scene_changed),
|
78
|
+
method(:on_input_mute_state_changed)
|
79
|
+
]
|
80
|
+
)
|
80
81
|
end
|
81
82
|
|
82
83
|
# define "on_" event methods.
|
83
|
-
def on_current_program_scene_changed
|
84
|
+
def on_current_program_scene_changed(data)
|
84
85
|
...
|
85
86
|
end
|
86
|
-
def on_input_mute_state_changed
|
87
|
+
def on_input_mute_state_changed(data)
|
87
88
|
...
|
88
89
|
end
|
89
90
|
...
|
data/lib/obsws/event.rb
CHANGED
@@ -43,7 +43,7 @@ module OBSWS
|
|
43
43
|
|
44
44
|
def add_observer(observer)
|
45
45
|
observer = [observer] if !observer.respond_to? :each
|
46
|
-
observer.each { |o| observers << o }
|
46
|
+
observer.each { |o| observers << o unless observers.include? o }
|
47
47
|
end
|
48
48
|
|
49
49
|
def remove_observer(observer)
|
@@ -52,15 +52,18 @@ module OBSWS
|
|
52
52
|
|
53
53
|
def notify_observers(event, data)
|
54
54
|
observers.each do |o|
|
55
|
-
if o.
|
56
|
-
if
|
57
|
-
o.
|
58
|
-
else
|
59
|
-
o.send("on_#{snakecase(event)}", data)
|
55
|
+
if o.is_a? Method
|
56
|
+
if o.name.to_s == "on_#{snakecase(event)}"
|
57
|
+
data.empty? ? o.call : o.call(data)
|
60
58
|
end
|
59
|
+
elsif o.respond_to? "on_#{snakecase(event)}"
|
60
|
+
data.empty? ? o.send("on_#{snakecase(event)}") : o.send("on_#{snakecase(event)}", data)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
alias_method :register, :add_observer
|
66
|
+
alias_method :deregister, :remove_observer
|
64
67
|
end
|
65
68
|
|
66
69
|
class Client
|
data/lib/obsws/version.rb
CHANGED
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.4.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-07-
|
11
|
+
date: 2023-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket-driver
|