mirror of
https://github.com/onyx-and-iris/obsws-ruby.git
synced 2026-04-18 13:33:31 +00:00
Callbacks module extended
Now supports callback methods as well observer classes levels example now uses callback methods register,deregister now alias add/remove observer methods minor version bump
This commit is contained in:
23
README.md
23
README.md
@@ -16,14 +16,10 @@
|
||||
### Bundler
|
||||
|
||||
```
|
||||
bundle add 'obsws'
|
||||
bundle add obsws
|
||||
bundle install
|
||||
```
|
||||
|
||||
### Gem
|
||||
|
||||
`gem install 'obsws'`
|
||||
|
||||
## `Use`
|
||||
|
||||
#### Example `main.rb`
|
||||
@@ -67,23 +63,28 @@ For a full list of requests refer to [Requests](https://github.com/obsproject/ob
|
||||
|
||||
### Events
|
||||
|
||||
Register an observer class and define `on_` methods for events. Method names should match the api event but snake cased.
|
||||
Register `on_` callback methods. Method names should match the api event but snake cased.
|
||||
|
||||
example:
|
||||
|
||||
```ruby
|
||||
class Observer
|
||||
def initialize
|
||||
@e_client = OBSWS::Events::Client.new(**kwargs)
|
||||
# register class with the event client
|
||||
@e_client.add_observer(self)
|
||||
@e_client = OBSWS::Events::Client.new(host: "localhost", port: 4455, password: "strongpassword")
|
||||
# register callback methods with the Event client
|
||||
@e_client.register(
|
||||
[
|
||||
method(:on_current_program_scene_changed),
|
||||
method(:on_input_mute_state_changed)
|
||||
]
|
||||
)
|
||||
end
|
||||
|
||||
# define "on_" event methods.
|
||||
def on_current_program_scene_changed
|
||||
def on_current_program_scene_changed(data)
|
||||
...
|
||||
end
|
||||
def on_input_mute_state_changed
|
||||
def on_input_mute_state_changed(data)
|
||||
...
|
||||
end
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user