mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-18 14:24:21 +01:00
Add implementation for BfxWebSocketClient::resubscribe and BfxWebSocketBucket::resubscribe.
This commit is contained in:
@@ -84,7 +84,8 @@ class BfxWebSocketBucket(Connection):
|
||||
_subscription = cast(Dict[str, Any], subscription)
|
||||
|
||||
await self.subscribe( \
|
||||
sub_id=_subscription.pop("subId"), **_subscription)
|
||||
sub_id=_subscription.pop("subId"),
|
||||
**_subscription)
|
||||
|
||||
self.__subscriptions.clear()
|
||||
|
||||
@@ -121,6 +122,18 @@ class BfxWebSocketBucket(Connection):
|
||||
|
||||
await self._websocket.send(message)
|
||||
|
||||
@Connection.require_websocket_connection
|
||||
async def resubscribe(self, sub_id: str) -> None:
|
||||
for subscription in self.__subscriptions.values():
|
||||
if subscription["subId"] == sub_id:
|
||||
_subscription = cast(Dict[str, Any], subscription)
|
||||
|
||||
await self.unsubscribe(sub_id=sub_id)
|
||||
|
||||
await self.subscribe( \
|
||||
sub_id=_subscription.pop("subId"),
|
||||
**_subscription)
|
||||
|
||||
@Connection.require_websocket_connection
|
||||
async def close(self, code: int = 1000, reason: str = str()) -> None:
|
||||
await self._websocket.close(code=code, reason=reason)
|
||||
|
||||
@@ -311,6 +311,12 @@ class BfxWebSocketClient(Connection, Connection.Authenticable):
|
||||
if bucket.has(sub_id=sub_id):
|
||||
await bucket.unsubscribe(sub_id=sub_id)
|
||||
|
||||
@Connection.require_websocket_connection
|
||||
async def resubscribe(self, sub_id: str) -> None:
|
||||
for bucket in self.__buckets:
|
||||
if bucket.has(sub_id=sub_id):
|
||||
await bucket.resubscribe(sub_id=sub_id)
|
||||
|
||||
@Connection.require_websocket_connection
|
||||
async def close(self, code: int = 1000, reason: str = str()) -> None:
|
||||
for bucket in self.__buckets:
|
||||
|
||||
Reference in New Issue
Block a user