コード例 #1
0
        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());
        }
コード例 #2
0
        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));
            }
        }