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
5 changes: 3 additions & 2 deletions dingtalk_stream/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DingTalkStreamClient(object):
OPEN_CONNECTION_API = DINGTALK_OPENAPI_ENDPOINT + '/v1.0/gateway/connections/open'
TAG_DISCONNECT = 'disconnect'

def __init__(self, credential: Credential, logger: logging.Logger = None):
def __init__(self, credential: Credential, logger: logging.Logger = None, websocket_connect_options=None):
self.credential: Credential = credential
self.event_handler: EventHandler = EventHandler()
self.callback_handler_map = {}
Expand All @@ -38,6 +38,7 @@ def __init__(self, credential: Credential, logger: logging.Logger = None):
self._pre_started = False
self._is_event_required = False
self._access_token = {}
self.websocket_connect_options = websocket_connect_options or {}

def register_all_event_handler(self, handler: EventHandler):
handler.dingtalk_client = self
Expand Down Expand Up @@ -71,7 +72,7 @@ async def start(self):
self.logger.info('endpoint is %s', connection)

uri = f'{connection["endpoint"]}?ticket={quote_plus(connection["ticket"])}'
async with websockets.connect(uri) as websocket:
async with websockets.connect(uri, **self.websocket_connect_options) as websocket:
self.websocket = websocket
asyncio.create_task(self.keepalive(websocket))
async for raw_message in websocket:
Expand Down