Skip to content

Commit 9d0429c

Browse files
committed
Add some simple docs
1 parent c9f3ebb commit 9d0429c

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A simple obs-websocket library in Python for people who just want JSON output. C
55
`pip install simpleobsws` [PyPi Link](https://pypi.org/project/simpleobsws/)
66

77
## Docs:
8-
- Library docs: Not yet
8+
- Library docs: [the sort-of docs](/usage.md)
99
- obs-websocket docs: https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md
1010

1111
## Samples:

usage.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# The sort-of docs
2+
3+
## Class `obsws`
4+
5+
### `def __init__(self, host='localhost', port=4444, password=None, call_poll_delay=100, loop: asyncio.BaseEventLoop=None):`
6+
7+
- `host` | Host to connect to. Can be a hostname or IP address.
8+
- `port` | Port that the obs-websocket server is listening on.
9+
- `password` | The password set on the obs-websocket server (if any).
10+
- `call_poll_delay` | When using the `obsws.call()` function, you may set the time that simpleobsws waits after every check for new responses.
11+
- `loop` | If you are using your own specific event loop, you may specify it so that simpleobsws submits and runs its tasks in that loop.
12+
13+
### `async def connect(self):`
14+
15+
Connect to the configured obs-websocket server and authenticate if the server requires authentication.
16+
17+
### `async def disconnect(self):`
18+
19+
Disconnect from the obs-websocket server. Once disconnected, the server may be connected to again using `connect()`.
20+
21+
### `async def call(self, request_type, data=None, timeout=15):`
22+
23+
Make a request to the obs-websocket server and return the response.
24+
25+
- `request_type` | The request-type of the request you want to make. Ex. `GetVersion`
26+
- `data` | Optional request data to pass to obs-websocket along with the request. Must be in the form of a [Python dictionary](https://docs.python.org/3/tutorial/datastructures.html#dictionaries).
27+
- `timeout` | How long to internally poll for obs-websocket responses before giving up and throwing a `MessageTimeout` error.
28+
29+
### `async def emit(self, request_type, data=None):`
30+
31+
Similar to the `call()` function, but does not poll for a websocket response, and does not return any values.
32+
33+
### `def register(self, function, event=None):`
34+
35+
Register a callback function for an obs-websocket event. *Must* be a coroutine.
36+
37+
- `function` | Callback to a handler function. See examples for more info.
38+
- `event` | Event to trigger the callback. If `None` is specified, all obs-websocket events will be sent to the callback.
39+
40+
### `def unregister(self, function, event=None):`
41+
42+
Similar to `register()`, but deregisters a callback function from obs-websocket. Requires matching `function` and `event` parameters to the original callback registration.

0 commit comments

Comments
 (0)