From 42ff902698d2b57dfd93fe1f0d5c2b3c948f9ec3 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Tue, 2 Aug 2022 09:32:23 +0100 Subject: [PATCH] vban_cmd.api section added to readme. Event updates section added to readme. Brief explanation regarding registering and toggling event subscriptions --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/README.md b/README.md index 912f579..398735f 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,60 @@ will load a config file at configs/banana/example.toml for Voicemeeter Banana. ### VbanCmd class +`vban_cmd.api(kind_id: str, **opts: dict)` + +You may pass the following optional keyword arguments: + +- `ip`: str, ip or hostname of remote machine +- `streamname`: str, name of the stream to connect to. +- `port`: int=6980, vban udp port of remote machine. +- `subs`: dict={"pdirty": True, "ldirty": False}, controls which updates to listen for. + - `pdirty`: parameter updates + - `ldirty`: level updates + +#### Event updates + +To receive event updates you should do the following: + +- register your app to receive updates using the `vm.subject.add(observer)` method, where observer is your app. +- define an `on_update(subject)` callback function in your app. The value of subject may be checked for the type of update. + +See `examples/observer` for a demonstration. + +Level updates are considered high volume, by default they are NOT listened for. + +Each of the update types may be enabled/disabled separately. + +example: + +```python +import vban_cmd +# Listen for level updates +opts = { + "ip": "", + "streamname": "Command1", + "port": 6980, + "subs": {"ldirty": True}, +} +with vban_cmd.api('banana', **opts) as vban: + ... +``` + +#### `vm.event` + +You may also add/remove event subscriptions as necessary with the Event class. + +example: + +```python +vm.event.add("ldirty") + +vm.event.remove("pdirty") + +# get a list of currently subscribed +print(vm.event.get()) +``` + #### `vban.pdirty` True iff a parameter has been changed.