/// <summary>
        /// modifies the device 3d type to "delete" and sends it to MQTT
        /// also tries to delete the WorldAnchors
        /// </summary>
        /// <param name="baseAdress"></param>
        public void sendDeleteOrderForWorldAnchorAndAppData(AppData.uniqueIDDevice device)
        {
            device.DeviceType3D = "delete";

            AppDataManager_MQTT.Instance.publishDeviceOverMQTT(device); //sends a device with the remove command to all active members in the network
            AppDataManager_MQTT.Instance.removeDeviceOverMQTT(device);  //sends a remove command to clean up the server


            var anchorInfo = WorldAnchorAvailableOnlineManager.Instance.getAnchorAvailableOnline(device.baseAdress);

            if (!anchorInfo.Equals(default(KeyValuePair <string, DateTime>)))//if there is an anchor available
            {
                AppDataExportManager.Instance.MQTTPublishMessage(AppDataExportManager.Instance.worldAnchorBaseSubscriptionPath +
                                                                 TimeMethodesForAnchors.getAnchorNameWithTimeFromKeyValuePair(anchorInfo),
                                                                 "");//deletion order for retained messages

                AppDataExportManager.Instance.MQTTPublishMessage(WorldAnchorAvailableOnlineManager.Instance.worldAnchorStatusSubscriptionPath +
                                                                 TimeMethodesForAnchors.getAnchorNameWithTimeFromKeyValuePair(anchorInfo),
                                                                 "");//deletion order for retained messages
            }


            //deletes wa info from the prefs
            PlayerPrefs.DeleteKey(device.baseAdress);

            //now remove the device locally
            removeDeviceFromAppDataAndDeleteFromHierarchie(device.baseAdress);
        }
Beispiel #2
0
        private void onAnchorAvailable(KeyValuePair <string, DateTime> anchor)
        {
            if (anchor.Equals(default(KeyValuePair <string, DateTime>)))
            {
                //no anchor has been found

                //fallback to any anchor from Store
                Debug.LogWarning("empty anchor given");
            }
            else
            {
                //3. decide wether to load the new anchor online or keep from store

                //if anchor.value is earlier than latest anchor
                //or the anchor from the store does not exist
                //or anchor is on override
                if (anchor.Value > latestAnchor || !WorldAnchorManager.Instance.hasAnchorInStore(gameObject) || anchorOrigin == AnchorOrigin.OverrideAnchorFromServer)
                {
                    //get the anchor from mqtt
                    //we have the name and the  time of the newest anchor
                    //generate a topic and subscribe to it
                    AppDataExportManager.Instance.subscribe(
                        AppDataExportManager.Instance.worldAnchorBaseSubscriptionPath +
                        TimeMethodesForAnchors.getAnchorNameWithTimeFromKeyValuePair(anchor),
                        onAnchorDataAvailable);
                }
            }
        }