[Fix] 修复一个BUG:WebSocketClient无法初始化:onDisconnected赋值错误

This commit is contained in:
nanoric 2018-10-16 05:45:16 -04:00
parent 995d994e8e
commit 1cc5c8b16e

View File

@ -38,7 +38,7 @@ class WebSocketClient(object):
self.host = None # type: str
self.onConnected = self.defaultOnConnected
self.onDisconnected = self.onDisconnected
self.onDisconnected = self.defaultOnDisconnected
self.onPacket = self.defaultOnPacket
self.onError = self.defaultOnError
@ -143,6 +143,9 @@ class WebSocketClient(object):
data = json.loads(stream)
self.onPacket(data)
except websocket.WebSocketConnectionClosedException:
if self._active:
self._reconnect()
except:
et, ev, tb = sys.exc_info()
self.onError(et, ev, tb)