@ -4,7 +4,6 @@ from websockets.client import WebSocketClientProtocol, connect as ws_connect_asy
|
||||
from websockets.sync.client import ClientConnection, connect as ws_connect
|
||||
|
||||
from ...client import Client
|
||||
from ...models.error import Error
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
@ -34,14 +33,7 @@ def sync(
|
||||
client=client,
|
||||
)
|
||||
|
||||
with ws_connect(
|
||||
kwargs["url"].replace("https://", "wss://"),
|
||||
additional_headers=kwargs["headers"],
|
||||
) as websocket:
|
||||
return websocket # type: ignore
|
||||
|
||||
# Return an error if we got here.
|
||||
return Error(message="An error occurred while connecting to the websocket.")
|
||||
return ws_connect(kwargs["url"].replace("http", "ws"), additional_headers=kwargs["headers"], close_timeout=None, compression=None, max_size=None) # type: ignore
|
||||
|
||||
|
||||
async def asyncio(
|
||||
@ -54,10 +46,6 @@ async def asyncio(
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with ws_connect_async(
|
||||
kwargs["url"].replace("https://", "wss://"), extra_headers=kwargs["headers"]
|
||||
) as websocket:
|
||||
return websocket
|
||||
|
||||
# Return an error if we got here.
|
||||
return Error(message="An error occurred while connecting to the websocket.")
|
||||
return ws_connect_async(
|
||||
kwargs["url"].replace("http", "ws"), extra_headers=kwargs["headers"]
|
||||
)
|
||||
|
Reference in New Issue
Block a user