Example #1
0
        /// <summary>
        /// Handles the user intent to resolve the cloud anchor associated with a room they have typed into the UI.
        /// </summary>
        public void OnResolveRoomClick()
        {
            var roomToResolve = UIManager.Instance().GetRoomInputValue();

            if (roomToResolve == 0)
            {
                UIManager.Instance().ShowResolvingModeBegin("Invalid room code.");
                return;
            }

            string ipAddress = UIManager.Instance().GetIpAddressInputValue();

            UIManager.Instance().ShowResolvingModeAttemptingResolve();
            RoomSharingClient roomSharingClient = new RoomSharingClient();

            roomSharingClient.GetAnchorIdFromRoom(roomToResolve, ipAddress, (bool found, string cloudAnchorId) =>
            {
                if (!found)
                {
                    UIManager.Instance().ShowResolvingModeBegin("Invalid room code.");
                }
                else
                {
                    _ResolveAnchorFromId(roomToResolve, cloudAnchorId);
                }
            });
        }
Example #2
0
        /// <summary>
        /// Handles the user intent to resolve the cloud anchor associated with a room they have typed into the UI.
        /// </summary>
        public void OnResolveRoomClick()
        {
            var roomToResolve = UIController.GetRoomInputValue();

            if (roomToResolve == 0)
            {
                UIController.ShowResolvingModeBegin("Anchor resolve failed due to invalid room code.");
                return;
            }

            UIController.SetRoomTextValue(roomToResolve);
            string ipAddress =
                UIController.GetResolveOnDeviceValue() ? k_LoopbackIpAddress : UIController.GetIpAddressInputValue();

            UIController.ShowResolvingModeAttemptingResolve();
            RoomSharingClient roomSharingClient = new RoomSharingClient();

            roomSharingClient.GetAnchorIdFromRoom(roomToResolve, ipAddress, (bool found, string cloudAnchorId) =>
            {
                if (!found)
                {
                    UIController.ShowResolvingModeBegin("Anchor resolve failed due to invalid room code, " +
                                                        "ip address or network error.");
                }
                else
                {
                    _ResolveAnchorFromId(cloudAnchorId);
                }
            });
        }
        /// <summary>
        /// Handles the user intent to resolve the cloud anchor associated with a room they have typed into the UI.
        /// </summary>
        public void OnResolveRoomClick()
        {
            FirebaseDatabase.DefaultInstance.GetReference("Anchors").LimitToLast(1).GetValueAsync().ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Debug.LogError("reference failed");
                    // Handle the error...
                }
                else if (task.IsCompleted)
                {
                    Debug.Log("task is complted");
                    DataSnapshot snapshot = task.Result;
                    GetSnapShotValues(snapshot);


                    UIController.SetRoomTextValue(roomToResolve);
                    string ipAddress = IP;
                    //UIController.GetResolveOnDeviceValue() ? k_LoopbackIpAddress : UIController.GetIpAddressInputValue();

                    UIController.ShowResolvingModeAttemptingResolve();
                    RoomSharingClient roomSharingClient = new RoomSharingClient();
                    roomSharingClient.GetAnchorIdFromRoom(roomToResolve, ipAddress, (bool found, string cloudAnchorId) =>
                    {
                        if (!found)
                        {
                            UIController.ShowResolvingModeBegin("Anchor resolve failed due to invalid room code, " +
                                                                "ip address or network error.");
                        }
                        else
                        {
                            _ResolveAnchorFromId(cloudAnchorId);
                        }
                    });


                    //roomToResolve = (int)snapshot.Child("Room").Value;
                    //IP = snapshot.Child("IP").ToString();
                    //treeScale = (float)snapshot.Child("scale").Value;
                    //Debug.Log("Room " + roomToResolve + "\n Ip :" + IP + "\n scale" + treeScale);
                    // Do something with snapshot...
                }
            });

            //WRITE DATABASE RETRIEVAL LOGIC HERE            //UIController.GetRoomInputValue();
            //if (roomToResolve == 0)
            //{
            //    UIController.ShowResolvingModeBegin("Anchor resolve failed due to invalid room code.");
            //    return;
            //}
        }