mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-01 12:32:25 +08:00
Updated signalrcore module following PR #61 merging.
This commit is contained in:
parent
cb09f8d440
commit
23ede4e7f9
2 changed files with 15 additions and 8 deletions
|
@ -56,6 +56,9 @@ class MessagePackHubProtocol(BaseHubProtocol):
|
|||
data = json.loads(handshake_data)
|
||||
return HandshakeResponseMessage(data.get("error", None)), messages
|
||||
except Exception as ex:
|
||||
if type(raw_message) is str:
|
||||
data = json.loads(raw_message[0: raw_message.index("}") + 1])
|
||||
return HandshakeResponseMessage(data.get("error", None)), []
|
||||
Helpers.get_logger().error(raw_message)
|
||||
Helpers.get_logger().error(ex)
|
||||
raise ex
|
||||
|
|
|
@ -128,9 +128,9 @@ class WebsocketTransport(BaseTransport):
|
|||
self.connection_checker.start()
|
||||
else:
|
||||
self.logger.error(msg.error)
|
||||
self.on_socket_error(msg.error)
|
||||
self.on_socket_error(self._ws, msg.error)
|
||||
self.stop()
|
||||
raise ValueError("Handshake error {0}".format(msg.error))
|
||||
self.state = ConnectionState.disconnected
|
||||
return messages
|
||||
|
||||
def on_open(self, _):
|
||||
|
@ -138,11 +138,15 @@ class WebsocketTransport(BaseTransport):
|
|||
msg = self.protocol.handshake_message()
|
||||
self.send(msg)
|
||||
|
||||
def on_close(self, _):
|
||||
def on_close(self, callback, close_status_code, close_reason):
|
||||
self.logger.debug("-- web socket close --")
|
||||
self.logger.debug(close_status_code)
|
||||
self.logger.debug(close_reason)
|
||||
self.state = ConnectionState.disconnected
|
||||
if self._on_close is not None and callable(self._on_close):
|
||||
self._on_close()
|
||||
if callback is not None and callable(callback):
|
||||
callback()
|
||||
|
||||
def on_reconnect(self):
|
||||
self.logger.debug("-- web socket reconnecting --")
|
||||
|
@ -150,7 +154,7 @@ class WebsocketTransport(BaseTransport):
|
|||
if self._on_close is not None and callable(self._on_close):
|
||||
self._on_close()
|
||||
|
||||
def on_socket_error(self, _, error):
|
||||
def on_socket_error(self, app, error):
|
||||
"""
|
||||
Args:
|
||||
_: Required to support websocket-client version equal or greater than 0.58.0
|
||||
|
@ -160,15 +164,15 @@ class WebsocketTransport(BaseTransport):
|
|||
HubError: [description]
|
||||
"""
|
||||
self.logger.debug("-- web socket error --")
|
||||
self.logger.error(traceback.format_exc(5, True))
|
||||
self.logger.error(traceback.format_exc(10, True))
|
||||
self.logger.error("{0} {1}".format(self, error))
|
||||
self.logger.error("{0} {1}".format(error, type(error)))
|
||||
self._on_close()
|
||||
raise HubError(error)
|
||||
self.state = ConnectionState.disconnected
|
||||
#raise HubError(error)
|
||||
|
||||
def on_message(self, _, raw_message):
|
||||
def on_message(self, app, raw_message):
|
||||
self.logger.debug("Message received{0}".format(raw_message))
|
||||
self.connection_checker.last_message = time.time()
|
||||
if not self.handshake_received:
|
||||
messages = self.evaluate_handshake(raw_message)
|
||||
if self._on_open is not None and callable(self._on_open):
|
||||
|
|
Loading…
Reference in a new issue