private void onAnchorDataAvailable(MqttNetClientAccess.mqttMessage message) { DateTime anchorTime = TimeMethodesForAnchors.parseAnchor(message.topic).Value; importInformation = new ImportInformation(3, message.payload, anchorTime); //TODO: what happens when one anchor gets available while the other is currently importing //then we should somehow stop the import of the other and use the new //we have the anchor now AppDataExportManager.Instance.unsubscribe(message.topic, onAnchorDataAvailable); WorldAnchorTransferBatch.ImportAsync(message.payload, onImportComplete); }
private void onAnchorDataAvailable(MqttNetClientAccess.mqttMessage message) { DateTime anchorTime = TimeMethodesForAnchors.parseAnchor(message.topic).Value; //we have the anchor now AppDataExportManager.Instance.unsubscribe(message.topic, onAnchorDataAvailable); //importInformation = new ImportInformation(3, message.payload, anchorTime); //TODO: what happens when one anchor gets available while the other is currently importing //then we should somehow stop the import of the other and use the new //this will start a new import process and kills the old if there is one currentImportProcess = new WorldAnchorImport(message.payload, importetAnchorFromWorldAnchorImport, anchorTime, 3); }
/// <summary> /// new anchor status will bee added trough here /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addWorldAnchorStatus(MqttNetClientAccess.mqttMessage message) { KeyValuePair <string, DateTime> newAnchorParsed = default(KeyValuePair <string, DateTime>); string[] tpcPth = null; string tpcPath_last = null; try { tpcPth = message.topic.Split('/'); //splits the topic path segments tpcPath_last = tpcPth[tpcPth.Length - 1]; //gets the last segment (name of the anchor with timestamp) Debug.Log("received message, added: " + tpcPath_last); newAnchorParsed = TimeMethodesForAnchors.parseAnchor(tpcPath_last); } catch { Debug.LogError("could not parse anchor: " + tpcPath_last); return; } if (message.payload.Length == 0) { return; //only valid messages get processed } //if there is already an anchor, remove it if (anchorsAvailableOnMqtt.ContainsKey(newAnchorParsed.Key)) //anchorsAvailableOnMqtt[newAnchorParsed.Key] < newAnchorParsed.Value) { if (anchorsAvailableOnMqtt[newAnchorParsed.Key] >= newAnchorParsed.Value) { return;//only lets newer anchors come into the list. older anchors gets dropped } anchorsAvailableOnMqtt.Remove(newAnchorParsed.Key); } //adds the anchor to the available anchors anchorsAvailableOnMqtt.Add(newAnchorParsed.Key, newAnchorParsed.Value); //now check if someone wants to be notified if (newAnchorAvailableDic.ContainsKey(newAnchorParsed.Key)) { newAnchorAvailableDic[newAnchorParsed.Key].Invoke(newAnchorParsed); } }