Allows users of the RoomManager to register to receive event callbacks without having their classes inherit directly from RoomManagerListener
Inheritance: RoomManagerListener
        protected override void OnDestroy()
        {
            if (sharingStage.SessionsTracker != null)
            {
                sharingStage.SessionsTracker.CurrentUserJoined -= CurrentUserJoinedSession;
                sharingStage.SessionsTracker.CurrentUserLeft   -= CurrentUserLeftSession;
            }

            if (roomManagerCallbacks != null)
            {
                roomManagerCallbacks.AnchorsDownloadedEvent -= RoomManagerCallbacks_AnchorsDownloaded;
                roomManagerCallbacks.AnchorUploadedEvent    -= RoomManagerCallbacks_AnchorUploaded;

                if (roomManager != null)
                {
                    roomManager.RemoveListener(roomManagerCallbacks);
                }

                roomManagerCallbacks.Dispose();
                roomManagerCallbacks = null;
            }

            if (roomManager != null)
            {
                roomManager.Dispose();
                roomManager = null;
            }

            base.OnDestroy();
        }
Beispiel #2
0
        /// <summary>
        /// Called when the sharing stage connects to a server.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">Events Arguements.</param>
        private void Connected(object sender = null, EventArgs e = null)
        {
            SharingStage.Instance.SharingManagerConnected -= Connected;

            if (SharingStage.Instance.ShowDetailedLogs)
            {
                Debug.Log("Anchor Manager: Starting...");
            }

            if (AnchorDebugText != null)
            {
                AnchorDebugText.text += "\nConnected to Server";
            }

            // Setup the room manager callbacks.
            roomManager         = SharingStage.Instance.Manager.GetRoomManager();
            roomManagerListener = new RoomManagerAdapter();

            roomManagerListener.AnchorsChangedEvent    += RoomManagerCallbacks_AnchorsChanged;
            roomManagerListener.AnchorsDownloadedEvent += RoomManagerListener_AnchorsDownloaded;
            roomManagerListener.AnchorUploadedEvent    += RoomManagerListener_AnchorUploaded;

            roomManager.AddListener(roomManagerListener);

            // We will register for session joined and left to indicate when the sharing service
            // is ready for us to make room related requests.
            SharingStage.Instance.SessionsTracker.CurrentUserJoined += CurrentUserJoinedSession;
            SharingStage.Instance.SessionsTracker.CurrentUserLeft   += CurrentUserLeftSession;
        }
Beispiel #3
0
        private void ManagerInit(bool setConnection)
        {
            var config = new ClientConfig(ClientRole);

            config.SetIsAudioEndpoint(IsAudioEndpoint);
            config.SetLogWriter(logWriter);

            if (setConnection)
            {
                config.SetServerAddress(ServerAddress);
                config.SetServerPort(ServerPort);
            }

            Manager = SharingManager.Create(config);

            // Set up callbacks so that we know when we've connected successfully.
            networkConnectionAdapter = new NetworkConnectionAdapter();
            networkConnectionAdapter.ConnectedCallback    += OnNetworkConnectionChanged;
            networkConnectionAdapter.DisconnectedCallback += OnNetworkConnectionChanged;
            Connection.AddListener((byte)MessageID.StatusOnly, networkConnectionAdapter);

            SyncStateListener = new SyncStateListener();
            Manager.RegisterSyncListener(SyncStateListener);

            Root = new SyncRoot(Manager.GetRootSyncObject());

            SessionsTracker     = new ServerSessionsTracker(Manager.GetSessionManager());
            SessionUsersTracker = new SessionUsersTracker(SessionsTracker);

            RoomManagerAdapter = new RoomManagerAdapter();

            CurrentRoomManager.AddListener(RoomManagerAdapter);

            using (var userName = new XString(DefaultUserName))
            {
#if UNITY_WSA && !UNITY_EDITOR
                Manager.SetUserName(SystemInfo.deviceName);
#else
                if (!string.IsNullOrEmpty(Environment.UserName))
                {
                    Manager.SetUserName(Environment.UserName);
                }
                else
                {
                    User localUser = Manager.GetLocalUser();
                    Manager.SetUserName(userName + localUser.GetID().ToString());
                }
#endif
            }
        }
        private void Start()
        {
            // We will register for session joined and left to indicate when the sharing service
            // is ready for us to make room related requests.
            sharingStage = SharingStage.Instance;
            sharingStage.SessionsTracker.CurrentUserJoined += CurrentUserJoinedSession;
            sharingStage.SessionsTracker.CurrentUserLeft   += CurrentUserLeftSession;

            // Setup the room manager callbacks.
            roomManager          = sharingStage.Manager.GetRoomManager();
            roomManagerCallbacks = new RoomManagerAdapter();

            roomManagerCallbacks.AnchorsDownloadedEvent += RoomManagerCallbacks_AnchorsDownloaded;
            roomManagerCallbacks.AnchorUploadedEvent    += RoomManagerCallbacks_AnchorUploaded;
            roomManager.AddListener(roomManagerCallbacks);
        }
    void Start()
    {
        Debug.Log("Import Export Manager starting");

        CurrentState = ImportExportState.Ready;

        // We need to get our local anchor store started up.
        CurrentState = ImportExportState.AnchorStore_Initializing;
        WorldAnchorStore.GetAsync(AnchorStoreReady);

        // We will register for session joined to indicate when the sharing service
        // is ready for us to make room related requests.
        SharingSessionTracker.Instance.SessionJoined += Instance_SessionJoined;

        // Setup the room manager callbacks.
        roomManager          = SharingStage.Instance.Manager.GetRoomManager();
        roomManagerCallbacks = new HoloToolkit.Sharing.RoomManagerAdapter();

        roomManagerCallbacks.AnchorsDownloadedEvent += RoomManagerCallbacks_AnchorsDownloaded;
        roomManagerCallbacks.AnchorUploadedEvent    += RoomManagerCallbacks_AnchorUploaded;
        roomManager.AddListener(roomManagerCallbacks);
    }