Skip to content

Commit

Permalink
Merge pull request #18 from noahhusby/docs/examples
Browse files Browse the repository at this point in the history
Do state update on connection events
  • Loading branch information
noahhusby authored Sep 11, 2024
2 parents c405b91 + 41dab4e commit 5121e62
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions aiostreammagic/stream_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ async def disconnect(self):
await self.connect_task
except asyncio.CancelledError:
pass
await self.do_state_update_callbacks()

def is_connected(self) -> bool:
"""Return True if device is connected."""
Expand Down Expand Up @@ -139,6 +140,7 @@ async def connect_handler(self, res):
self._allow_state_update = True

res.set_result(True)
await self.do_state_update_callbacks()
await asyncio.wait([x], return_when=asyncio.FIRST_COMPLETED)

@staticmethod
Expand Down
3 changes: 2 additions & 1 deletion examples/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ async def main():

await client.disconnect()

if __name__ == '__main__':

if __name__ == "__main__":
asyncio.run(main())
3 changes: 2 additions & 1 deletion examples/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ async def on_state_change(client: StreamMagicClient):
print(f"Play State: {client.get_play_state()}")
print(f"Now Playing: {client.get_now_playing()}")


async def main():
"""Subscribe demo entrypoint."""
client = StreamMagicClient("192.168.20.218")
Expand All @@ -25,5 +26,5 @@ async def main():
await client.disconnect()


if __name__ == '__main__':
if __name__ == "__main__":
asyncio.run(main())
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aiostreammagic"
version = "2.2.3"
version = "2.2.4"
description = "An async python package for interfacing with Cambridge Audio / Stream Magic compatible streamers."
authors = ["Noah Husby <32528627+noahhusby@users.noreply.github.com>"]
maintainers = ["Noah Husby <32528627+noahhusby@users.noreply.github.com>"]
Expand Down

0 comments on commit 5121e62

Please sign in to comment.