microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6.01k stars 2.12k forks source link

How could we delete all the anchors inside the room on the server(clear the room)? #759

Closed EvgeniiKramzyuk closed 7 years ago

EvgeniiKramzyuk commented 7 years ago

How could we delete all the anchors inside the room on the server(clear the room) when it's connected to the server (SharingService)? When we try to import the anchor from the room all the anchors are uploaded (WorldAnchorTransferBatch.ImportAsync). It's just wasting of time. I need just one anchor. How can I clear the room of the anchors or send the request to get the particular anchor?

StephenHodgson commented 7 years ago

Have you tried out my recent PR addressing this?

https://github.com/Microsoft/HoloToolkit-Unity/pull/742

EvgeniiKramzyuk commented 7 years ago

Not yet in the workplace. This will definitely help remove anchors from the server?

StephenHodgson commented 7 years ago

Good point. I'll make sure to add that.

StephenHodgson commented 7 years ago

@EvgeniiKramzyuk, I don't think there's currently any way to remove an anchor from the room in the sharing service. That would have to be updated in the main HoloToolkit.

You would need to close the room, and make a new one and join it to reset all the anchors. Be sure to mark keepAlive = false so the room doesn't live after all users close the room.

EvgeniiKramzyuk commented 7 years ago

The fact is that I need the same room.

StephenHodgson commented 7 years ago

Currently the Sharing Service does not support that.

StephenHodgson commented 7 years ago

If you're just trying to get a single anchor you could always get the anchor name and just download the single one. Check out the InportExportAncorManager for an example of this.

XString roomAnchorId = SharingStage.Instance.CurrentRoom.GetAnchorName("MyAnchor");
if(roomAnchorId != null)
{
    roomManager.DownloadAnchor(SharingStage.Instance.CurrentRoom, roomAnchorId.GetString());
}
EvgeniiKramzyuk commented 7 years ago

Thank, I'll try it

EvgeniiKramzyuk commented 7 years ago

@StephenHodgson This method does not help.

XString roomAnchorId = SharingStage.Instance.CurrentRoom.GetAnchorName("MyAnchor"); if(roomAnchorId != null) { roomManager.DownloadAnchor(SharingStage.Instance.CurrentRoom, roomAnchorId.GetString()); }

I believe that this method loads all the anchors from the server, and issues only the one I specified in the parameters.

If there is an one anchor in room, then I event RoomManagerCallbacks_AnchorsDownloaded shows 800.000 bytes (approximately). And if there are 10-12 anchors, then it shows 11.000.000 bytes (approximately).

private void RoomManagerCallbacks_AnchorsDownloaded(bool successful, AnchorDownloadRequest request, XString failureReason)
    {
        // If we downloaded anchor data successfully we should import the data.
        if (successful)
        {
            int datasize = request.GetDataSize();
            Debug.Log(datasize + " bytes ");
            rawAnchorData = new byte[datasize];
            request.GetData(rawAnchorData, datasize);
            CurrentState = ImportExportState.DataReady;
        }
        else
        {
            // If we failed, we can ask for the data again.
            box.GetComponent<TextMesh>().text += "\n" + "Anchor DL failed " + failureReason;
            Debug.Log("Anchor DL failed " + failureReason);
            MakeAnchorDataRequest();
        }
    }
StephenHodgson commented 7 years ago

I suggest opening an issue on the main MixedRealityToolkitRepo addressing this enhancement to the sharing service