Skip to content

Commit

Permalink
Merge pull request #55 from swimos/callbacks
Browse files Browse the repository at this point in the history
Additional Callbacks
  • Loading branch information
DobromirM authored Jun 27, 2024
2 parents d08a8df + d6ff8a8 commit 67213ed
Show file tree
Hide file tree
Showing 7 changed files with 543 additions and 59 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

setuptools.setup(
name='swimos',
version='1.3.0-alpha',
version='1.4.0-alpha',
author='Dobromir Marinov',
author_email='dobromir@swim.it',
description='Standalone Python framework for building massively real-time streaming WARP clients.',
Expand Down
60 changes: 60 additions & 0 deletions swimos/client/_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ async def _subscribe(self, downlink_view: '_DownlinkView') -> None:
await self._open()

await self.__subscribers._register_downlink_view(downlink_view)
await downlink_view._execute_did_open()

async def _unsubscribe(self, downlink_view: '_DownlinkView') -> None:
"""
Expand All @@ -158,6 +159,7 @@ async def _unsubscribe(self, downlink_view: '_DownlinkView') -> None:
"""

await self.__subscribers._deregister_downlink_view(downlink_view)
await downlink_view._execute_did_close()
if not self._has_subscribers():
await self._close()

Expand Down Expand Up @@ -187,6 +189,8 @@ async def _wait_for_messages(self) -> None:
message = await self.websocket.recv()
response = _Envelope._parse_recon(message)
await self.__subscribers._receive_message(response)
# except:
# pass
finally:
await self._close()

Expand Down Expand Up @@ -336,6 +340,62 @@ async def _receive_message(self, message: '_Envelope') -> None:

await self.downlink_model._receive_message(message)

async def _subscribers_will_receive(self, message: '_Envelope') -> None:
"""
Execute the `will_receive` method of all downlink views of the downlink manager.
"""
for view in self.__downlink_views.values():
await view._execute_will_receive(message)

async def _subscribers_did_receive(self, message: '_Envelope') -> None:
"""
Execute the `did_receive` method of all downlink views of the downlink manager.
"""
for view in self.__downlink_views.values():
await view._execute_did_receive(message)

async def _subscribers_will_link(self) -> None:
"""
Execute the `will_link` method of all downlink views of the downlink manager.
"""
for view in self.__downlink_views.values():
await view._execute_will_link()

async def _subscribers_did_link(self) -> None:
"""
Execute the `did_link` method of all downlink views of the downlink manager.
"""
for view in self.__downlink_views.values():
await view._execute_did_link()

async def _subscribers_will_unlink(self) -> None:
"""
Execute the `will_unlink` method of all downlink views of the downlink manager.
"""
for view in self.__downlink_views.values():
await view._execute_will_unlink()

async def _subscribers_did_unlink(self) -> None:
"""
Execute the `did_link` method of all downlink views of the downlink manager.
"""
for view in self.__downlink_views.values():
await view._execute_did_unlink()

async def _subscribers_will_sync(self) -> None:
"""
Execute the `will_sync` method of all downlink views of the downlink manager.
"""
for view in self.__downlink_views.values():
await view._execute_will_sync()

async def _subscribers_did_sync(self) -> None:
"""
Execute the `did_sync` method of all downlink views of the downlink manager.
"""
for view in self.__downlink_views.values():
await view._execute_did_sync()

async def _subscribers_did_set(self, current_value: Any, old_value: Any) -> None:
"""
Execute the `did_set` method of all value downlink views of the downlink manager.
Expand Down
Loading

0 comments on commit 67213ed

Please sign in to comment.