RemoveListener() публичный Метод

public RemoveListener ( byte messageType, NetworkConnectionListener oldListener ) : void
messageType byte
oldListener NetworkConnectionListener
Результат void
Пример #1
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            if (discoveryClient != null)
            {
                discoveryClient.RemoveListener(discoveryClientAdapter);
                discoveryClient.Dispose();
                discoveryClient = null;

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

            if (Manager != null)
            {
                // Force a disconnection so that we can stop and start Unity without connections hanging around
                Manager.GetPairedConnection().Disconnect();
                Manager.GetServerConnection().Disconnect();
            }

            // Release the Sharing resources
            if (SessionUsersTracker != null)
            {
                SessionUsersTracker.Dispose();
                SessionUsersTracker = null;
            }

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

            if (networkConnection != null)
            {
                networkConnection.RemoveListener((byte)MessageID.StatusOnly, networkConnectionAdapter);
                networkConnection.Dispose();
                networkConnection = null;

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

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

            // Forces a garbage collection to try to clean up any additional reference to SWIG-wrapped objects
            GC.Collect();
        }
Пример #2
0
        void OnDestroy()
        {
            if (this.sharingMgr != null)
            {
                PairingManager pairingMgr = sharingMgr.GetPairingManager();
                pairingMgr.CancelPairing();     // Safe to call, even if no pairing is in progress.  Will not cause a disconnect

                // Remove our listener from the paired connection
                NetworkConnection pairedConnection = sharingMgr.GetPairedConnection();
                pairedConnection.RemoveListener((byte)MessageID.StatusOnly, this.connectionAdapter);
            }
        }
Пример #3
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            if (serverConnection != null)
            {
                for (byte index = (byte)TestMessageID.HeadTransform; index < (byte)TestMessageID.Max; index++)
                {
                    serverConnection.RemoveListener(index, connectionAdapter);
                }
                connectionAdapter.MessageReceivedCallback -= OnMessageReceived;
            }
        }
Пример #4
0
        void OnDestroy()
        {
            // SharingStage's OnDestroy() might execute first in the script order. Therefore we should check if
            // SharingStage.Instance still exists. Without the instance check, the execution of GetPairingManager
            // on a disposed sharing manager will crash the Unity Editor and application.
            if (SharingStage.Instance != null && this.sharingMgr != null)
            {
                PairingManager pairingMgr = sharingMgr.GetPairingManager();
                pairingMgr.CancelPairing();     // Safe to call, even if no pairing is in progress.  Will not cause a disconnect

                // Remove our listener from the paired connection
                NetworkConnection pairedConnection = sharingMgr.GetPairedConnection();
                pairedConnection.RemoveListener((byte)MessageID.StatusOnly, this.connectionAdapter);
            }
        }
Пример #5
0
        protected override void OnDestroy()
        {
            if (discoveryClient != null)
            {
                discoveryClient.RemoveListener(discoveryClientAdapter);
                discoveryClient.Dispose();
                discoveryClient = null;

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

            if (networkConnection != null)
            {
                networkConnection.RemoveListener((byte)MessageID.StatusOnly, networkConnectionAdapter);
                networkConnection.Dispose();
                networkConnection = null;

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

            if (sharingMgr != null)
            {
                // Force a disconnection so that we can stop and start Unity without connections hanging around
                sharingMgr.GetPairedConnection().Disconnect();
                sharingMgr.GetServerConnection().Disconnect();

                // Release the XTools manager so that it cleans up the C++ copy
                sharingMgr.Dispose();
                sharingMgr = null;
            }

            // Forces a garbage collection to try to clean up any additional reference to SWIG-wrapped objects
            GC.Collect();

            base.OnDestroy();
        }