Skip to content

Commit ec91d65

Browse files
Merge pull request #48 from luar123/docu2
Add callback and polling example
2 parents 7a934c9 + 843a35b commit ec91d65

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ for client in server.clients:
2727
# set volume for client #0 to 50%
2828
client = server.clients[0]
2929
loop.run_until_complete(server.client_volume(client.identifier, {'percent': 50, 'muted': False}))
30+
31+
# create background task (polling)
32+
async def testloop():
33+
while(1):
34+
print("still running")
35+
#print(json.dumps(server.streams[0].properties, indent=4))
36+
print(server.groups)
37+
await asyncio.sleep(10)
38+
39+
test = loop.create_task(testloop())
40+
41+
# add callback for client #0 volume change
42+
def my_update_func(client):
43+
print(client.volume)
44+
45+
server.clients[0].set_callback(my_update_func)
46+
47+
# keep loop running to receive callbacks and to keep background task alive
48+
loop.run_forever()
3049
```
3150

3251
### Client

0 commit comments

Comments
 (0)