Rename AuthenticatedChannelsHandler to AuthenticatedEventsHandler (and bfxapi.websocket.handlers.authenticated_channels_handler to authenticated_events_handler).

This commit is contained in:
Davide Casale
2023-04-19 04:29:26 +02:00
parent 3d9e7c7b25
commit 3de6eee337
3 changed files with 7 additions and 7 deletions

View File

@@ -11,7 +11,7 @@ from pyee.asyncio import AsyncIOEventEmitter
from .bfx_websocket_bucket import _HEARTBEAT, F, _require_websocket_connection, BfxWebsocketBucket
from .bfx_websocket_inputs import BfxWebsocketInputs
from ..handlers import PublicChannelsHandler, AuthenticatedChannelsHandler
from ..handlers import PublicChannelsHandler, AuthenticatedEventsHandler
from ..exceptions import WebsocketAuthenticationRequired, InvalidAuthenticationCredentials, EventNotSupported, \
ZeroConnectionsError, ReconnectionTimeoutError, OutdatedClientVersion
@@ -60,7 +60,7 @@ class BfxWebsocketClient:
EVENTS = [
*ONCE_EVENTS, "subscribed", "wss-error",
*PublicChannelsHandler.EVENTS,
*AuthenticatedChannelsHandler.EVENTS
*AuthenticatedEventsHandler.EVENTS
]
def __init__(self, host, credentials, *, wss_timeout = 60 * 15, log_filename = None, log_level = "INFO"):
@@ -70,7 +70,7 @@ class BfxWebsocketClient:
self.event_emitter = AsyncIOEventEmitter()
self.handler = AuthenticatedChannelsHandler(event_emitter=self.event_emitter)
self.handler = AuthenticatedEventsHandler(event_emitter=self.event_emitter)
self.inputs = BfxWebsocketInputs(handle_websocket_input=self.__handle_websocket_input)

View File

@@ -1,2 +1,2 @@
from .public_channels_handler import PublicChannelsHandler
from .authenticated_channels_handler import AuthenticatedChannelsHandler
from .authenticated_events_handler import AuthenticatedEventsHandler

View File

@@ -4,7 +4,7 @@ from .. serializers import _Notification
from .. exceptions import HandlerNotFound
class AuthenticatedChannelsHandler:
class AuthenticatedEventsHandler:
__abbreviations = {
"os": "order_snapshot", "on": "order_new", "ou": "order_update",
"oc": "order_cancel", "ps": "position_snapshot", "pn": "position_new",
@@ -43,9 +43,9 @@ class AuthenticatedChannelsHandler:
if abbrevation == "n":
return self.__notification(stream)
for abbrevations, serializer in AuthenticatedChannelsHandler.__serializers.items():
for abbrevations, serializer in AuthenticatedEventsHandler.__serializers.items():
if abbrevation in abbrevations:
event = AuthenticatedChannelsHandler.__abbreviations[abbrevation]
event = AuthenticatedEventsHandler.__abbreviations[abbrevation]
if all(isinstance(substream, list) for substream in stream):
return self.event_emitter.emit(event, [ serializer.parse(*substream) for substream in stream ])