Rewrite AuthenticatedEventsHandler with _label_array_elements logic. Add support to multiple new events. Fix bug in BfxWebsocketClient.py.

This commit is contained in:
Davide Casale
2022-11-10 11:57:57 +01:00
parent 50644e8116
commit 61b082db2e
2 changed files with 136 additions and 7 deletions

View File

@@ -43,9 +43,9 @@ class BfxWebsocketClient(object):
if message["status"] == "OK":
self.event_emitter.emit("authenticated", message)
else: raise AuthenticationCredentialsError("Cannot authenticate with given API-KEY and API-SECRET.")
elif isinstance(message, list) and (chanId := message[0]) and message[1] != HEARTBEAT:
elif isinstance(message, list) and ((chanId := message[0]) or True) and message[1] != HEARTBEAT:
if chanId == 0:
self.handlers["authenticated"].handle(message[1], *message[2:])
self.handlers["authenticated"].handle(message[1], message[2])
else: self.handlers["public"].handle(self.chanIds[chanId], *message[1:])
except websockets.ConnectionClosed:
continue