async def handle(self, connection: ConnectionAPI, msg: Payload) -> None: msg = cast(Dict[str, Any], msg) try: reason = DisconnectReason(msg['reason']) except TypeError: self.logger.debug('Got unknown disconnect reason reason: %s', msg) else: self.disconnect_reason = reason if connection.is_operational: connection.cancel_nowait()
async def handle(self, connection: ConnectionAPI, cmd: Disconnect) -> None: self.disconnect_reason = cmd.payload if connection.is_operational: connection.cancel_nowait()