Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,13 @@ async def connect(self):
"""Establishes a WebSocket connection using authentication."""
host = self.WS_BASE_URL + self.url_suffix
auth_headers = self.request_headers("GET", self.url_suffix)
async with websockets.connect(host, additional_headers=auth_headers) as websocket:
self.ws = websocket
await self.on_open()
await self.handler()
self.ws = await websockets.connect(
host,
additional_headers=auth_headers,
)

await self.on_open()
await self.handler()

async def on_open(self):
"""Callback when WebSocket connection is opened."""
Expand Down Expand Up @@ -231,4 +234,4 @@ async def on_error(self, error):

async def on_close(self, close_status_code, close_msg):
"""Callback when WebSocket connection is closed."""
print("WebSocket connection closed with code:", close_status_code, "and message:", close_msg)
print("WebSocket connection closed with code:", close_status_code, "and message:", close_msg)