mirror of
https://github.com/xfgryujk/blivedm.git
synced 2024-12-25 20:30:08 +08:00
客户端正常停止也调用回调
This commit is contained in:
parent
e99dc7c5a3
commit
e9d4bf47cf
@ -232,8 +232,8 @@ class WebSocketClientBase:
|
||||
logger.debug('room=%s _network_coroutine() finished', self.room_id)
|
||||
self._network_future = None
|
||||
|
||||
if exc is not None and self._handler is not None:
|
||||
self._handler.on_stopped_by_exception(self, exc)
|
||||
if self._handler is not None:
|
||||
self._handler.on_client_stopped(self, exc)
|
||||
|
||||
async def _network_coroutine(self):
|
||||
"""
|
||||
@ -454,6 +454,8 @@ class WebSocketClientBase:
|
||||
|
||||
:param command: 业务消息
|
||||
"""
|
||||
if self._handler is None:
|
||||
return
|
||||
try:
|
||||
# 为什么不做成异步的:
|
||||
# 1. 为了保持处理消息的顺序,这里不使用call_soon、create_task等方法延迟处理
|
||||
|
@ -48,9 +48,9 @@ class HandlerInterface:
|
||||
def handle(self, client: ws_base.WebSocketClientBase, command: dict):
|
||||
raise NotImplementedError
|
||||
|
||||
def on_stopped_by_exception(self, client: ws_base.WebSocketClientBase, exception: Exception):
|
||||
def on_client_stopped(self, client: ws_base.WebSocketClientBase, exception: Optional[Exception]):
|
||||
"""
|
||||
当客户端被异常停止时调用。可以在这里close或者重新start
|
||||
当客户端停止时调用。可以在这里close或者重新start
|
||||
"""
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user