private OperationResult StartClientService(CameraConfig config) { bool success = false; long id = Utils.IpAddressToLong(config.IpAddress); if (clientServices.ContainsKey(id)) { return(ErrorOperationResult($"[StartClientService:Init] More than one camera configuration with same IP address: {config.IpAddress}. Skiping the duplicate instance.")); } var clientService = new HttpService(id, config); // HttpServiec constructor should throw in case of any issues. clientService.Start().ContinueWith(t => success = t.Result).Wait(ServiceInitTmieoutMs); //Wait should re-throw any exceptions during initialization. if (success) { clientServices.Add(id, clientService); } else { return(ErrorOperationResult($"[StartClientService:Init] Could not initialize monitoring service for camera with IP address {config.IpAddress}.")); } return(SuccessOperationResult()); }
internal HttpService(long id, CameraConfig config) { _config = config; _id = id; }