Esempio n. 1
0
        /// <summary>
        /// Uploads outstanding diagnostics sessions
        /// </summary>
        /// <param name="subscription">class with account information</param>
        /// <returns>true if any of the sessions uploaded. false if none did.</returns>
        public async Task <bool> UploadDiagnosticsAsync(ObjectAnchorsSubscription subscription)
        {
            Debug.Log("Uploading diagnostics");
            bool           uploaded     = false;
            Queue <string> failureQueue = new Queue <string>();

            while (_diagnosticsFilePaths.Count > 0)
            {
                string diagnosticsFilePath = _diagnosticsFilePaths.Dequeue();
                Debug.Log($"uploading {diagnosticsFilePath}");
                // Uploading may take long when the network is slow or the diagnostics file is large.
                if (await _objectAnchorsService.UploadDiagnosticsAsync(diagnosticsFilePath, subscription.AccountId, subscription.AccountKey, subscription.AccountDomain))
                {
                    Debug.Log($"'{diagnosticsFilePath}' has been uploaded to Object Anchors blob storage.");

                    File.Delete(diagnosticsFilePath);

                    uploaded = true;
                }
                else
                {
                    Debug.LogWarning($"failed to upload {diagnosticsFilePath}");
                    if (File.Exists(diagnosticsFilePath))
                    {
                        // requeue it if the user wants to try again later.
                        failureQueue.Enqueue(diagnosticsFilePath);
                    }
                }
            }

            _diagnosticsFilePaths = failureQueue;
            Debug.Log($"Uploading diagnostics complete. any uploads? {uploaded} remaining: {_diagnosticsFilePaths.Count}");
            return(uploaded);
        }
Esempio n. 2
0
        public static async Task <ObjectAnchorsSubscription> LoadObjectAnchorsSubscriptionIfExists()
        {
            ObjectAnchorsSubscription subscripton = null;

            var subscriptionFilePath = Path.Combine(Application.persistentDataPath, "subscription.json").Replace('/', '\\');

            if (File.Exists(subscriptionFilePath))
            {
                using (var reader = new StreamReader(subscriptionFilePath))
                {
                    var content = await reader.ReadToEndAsync();

                    try
                    {
                        subscripton = JsonUtility.FromJson <ObjectAnchorsSubscription>(content);

                        if (string.IsNullOrEmpty(subscripton.AccountId) || string.IsNullOrEmpty(subscripton.AccountKey) || string.IsNullOrEmpty(subscripton.AccountDomain))
                        {
                            Debug.LogWarning("Invalid Azure Object Anchors subscription information.");

                            subscripton = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError($"Fail to load Azure Object Anchors subscription from '{subscriptionFilePath}'. Exception message: '{ex.ToString()}'.");
                    }
                }
            }

            return(subscripton);
        }
Esempio n. 3
0
        private async void UploadTracing()
        {
            _textToSpeech.Speak("Start uploading diagnostics.");
            ObjectAnchorsSubscription subscription = await ObjectAnchorsSubscription.LoadObjectAnchorsSubscriptionIfExists();

            if (subscription != null)
            {
                bool uploaded = await ObjectTrackerDiagnostics.Instance.UploadDiagnosticsAsync(subscription);

                _textToSpeech.Speak("Diagnostics uploading " + (uploaded ? " succeeded." : " failed."));
            }
            else
            {
                _textToSpeech.Speak("Subscription not found");
            }
        }