public StopTimelapseResponse StopTimelapse(StopTimelapseRequest req) { if (!IsTakingTimelapse()) { return(new StopTimelapseResponse() { ErrorMessage = "No timelapse being taken" }); } this.timelapseCts.Cancel(); Logger.Log($"Timelapse {currentTimelapseId ?? string.Empty} stopped"); return(new StopTimelapseResponse()); }
private static MethodResponse StopTimelapseAsync(MethodRequest methodRequest, ModuleClient moduleClient) { try { var req = StopTimelapseRequest.FromJson(methodRequest.DataAsJson); var response = camera.StopTimelapse(req); var responseAsBytes = GetJsonBytes(response); return(new MethodResponse( responseAsBytes, response.Succeded ? (int)HttpStatusCode.OK : (int)HttpStatusCode.Conflict )); } catch (Exception ex) { Logger.LogError(ex, "Failed to start new timelapse"); return(new MethodResponse( Encoding.UTF8.GetBytes($"Error starting timelapse: {ex.Message}"), (int)HttpStatusCode.InternalServerError)); } }