public override void OnCreateFailed(XString reason) { LogWriteLine("********* SESSION CREATE FAILED: " + reason.GetString() + " ******"); if (CreateFailed != null) { CreateFailed(reason); } }
/// <summary> /// Called when anchor upload operations complete. /// </summary> private void RoomManagerCallbacks_AnchorUploaded(bool successful, HoloToolkit.Sharing.XString failureReason) { if (successful) { CurrentState = ImportExportState.Ready; } else { Debug.Log("Upload failed " + failureReason); CurrentState = ImportExportState.Failed; } }
/// <summary> /// Kicks off the process of creating the shared space. /// </summary> void StartAnchorProcess() { // First, are there any anchors in this room? int anchorCount = currentRoom.GetAnchorCount(); Debug.Log(anchorCount + " anchors"); // If there are anchors, we should attach to the first one. if (anchorCount > 0) { // Extract the name of the anchor. HoloToolkit.Sharing.XString storedAnchorString = currentRoom.GetAnchorName(0); string storedAnchorName = storedAnchorString.GetString(); // Attempt to attach to the anchor in our local anchor store. if (AttachToCachedAnchor(storedAnchorName) == false) { Debug.Log("Starting room download"); // If we cannot find the anchor by name, we will need the full data blob. MakeAnchorDataRequest(); } } }
public override void OnCreateFailed(XString reason) { LogWriteLine("********* SESSION CREATE FAILED: " + reason.GetString() + " ******"); CreateFailed?.Invoke(reason); }
// Helper to create a session public bool CreateSession(string sessionName) { XString nameXString = new XString(sessionName); LogWriteLine("Creating Session " + sessionName); if (!this.SessionManager.CreateSession(nameXString)) { LogWriteLine("Failed to request a new session!"); return false; } return true; }
// Helper to join a session public bool JoinSession(string sessionName) { XString nameXString = new XString(sessionName); bool foundSession = false; for (int i = 0; i < this.SessionManager.GetSessionCount(); ++i) { Session session = this.SessionManager.GetSession(i); if (session.GetName().IsEqual(nameXString)) { LogWriteLine("Joining Session " + sessionName); if (session.Join()) { LogWriteLine("Join request sent"); foundSession = true; } else { LogWriteLine("Failed to join session!"); } break; } } return foundSession; }
/// <summary> /// Called when anchor download operations complete. /// </summary> private void RoomManagerCallbacks_AnchorsDownloaded(bool successful, HoloToolkit.Sharing.AnchorDownloadRequest request, HoloToolkit.Sharing.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. Debug.Log("Anchor DL failed " + failureReason); MakeAnchorDataRequest(); } }
public override BoolElement CreateBoolElement(XString name, bool value) { return(new BoolElementLoopback(name, value)); }
internal ObjectElementLoopback(XString name, XString objectType) : base(IntPtr.Zero, false) { this.name = name; elementArray = new List <Element>(); }
internal ObjectElementLoopback(IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { name = new XString("Root"); elementArray = new List <Element>(); }
internal BoolElementLoopback(XString name, bool value) : base(IntPtr.Zero, false) { this.name = name; this.value = value; }
/// <summary> /// Called before creating anchor. Used to check if import required. /// </summary> /// <param name="anchorId">Name of the anchor to import.</param> /// <param name="objectToAnchor">GameObject </param> /// <returns>Success.</returns> protected override bool ImportAnchor(string anchorId, GameObject objectToAnchor) { if (SharingStage.Instance == null || SharingStage.Instance.Manager == null || SharingStage.Instance.CurrentRoom == null) { Debug.LogErrorFormat("[SharingWorldAnchorManager] Failed to import anchor \"{0}\"! The sharing service was not ready.", anchorId); if (AnchorDebugText != null) { AnchorDebugText.text += string.Format("\nFailed to import anchor \"{0}\"! The sharing service was not ready.", anchorId); } return(false); } int roomAnchorCount = SharingStage.Instance.CurrentRoom.GetAnchorCount(); for (int i = 0; i < roomAnchorCount; i++) { XString roomAnchorId = SharingStage.Instance.CurrentRoom.GetAnchorName(i); if (roomAnchorId.GetString().Equals(anchorId)) { bool downloadStarted = SharingStage.Instance.CurrentRoomManager.DownloadAnchor(SharingStage.Instance.CurrentRoom, anchorId); if (downloadStarted) { if (ShowDetailedLogs) { Debug.Log("[SharingWorldAnchorManager] Found a match! Attempting to download anchor..."); } if (AnchorDebugText != null) { AnchorDebugText.text += "\nFound a match! Attempting to download anchor..."; } } else { Debug.LogWarning("[SharingWorldAnchorManager] Found a match, but we've failed to start download!"); if (AnchorDebugText != null) { AnchorDebugText.text += "\nFound a match, but we've failed to start download!"; } } return(downloadStarted); } } if (ShowDetailedLogs) { Debug.LogFormat("[SharingWorldAnchorManager] No matching anchor found for \"{0}\" in room {1}.", anchorId, SharingStage.Instance.CurrentRoom.GetName().GetString()); } if (AnchorDebugText != null) { AnchorDebugText.text += string.Format("\nNo matching anchor found for \"{0}\" in room {1}.", anchorId, SharingStage.Instance.CurrentRoom.GetName().GetString()); } return(false); }
/// <summary> /// Called when anchor download operations complete. /// </summary> private void RoomManagerListener_AnchorDownloaded(bool successful, AnchorDownloadRequest request, XString failureReason) { // If we downloaded anchor data successfully we should import the data. if (successful) { int dataSize = request.GetDataSize(); if (ShowDetailedLogs) { Debug.LogFormat("[SharingWorldAnchorManager] Downloaded {0} bytes.", dataSize.ToString()); } if (AnchorDebugText != null) { AnchorDebugText.text += string.Format("\nDownloaded {0} bytes.", dataSize.ToString()); } rawAnchorDownloadData = new byte[dataSize]; request.GetData(rawAnchorDownloadData, dataSize); shouldImportAnchors = true; } else { Debug.LogWarning("[SharingWorldAnchorManager] Anchor DL failed " + failureReason); if (AnchorDebugText != null) { AnchorDebugText.text += string.Format("\nAnchor DL failed " + failureReason); } } }