예제 #1
0
파일: RuyiSDK.cs 프로젝트: zaga-ruyi/sdk
        /// <summary>
        /// Dispose the SDK instance, don't miss this after SDK usage.
        /// </summary>
        public void Dispose()
        {
            Subscriber?.Dispose();
            Subscriber = null;

            Storage?.Dispose();
            Storage = null;

            RuyiNetService?.Dispose();
            RuyiNetService = null;

            SettingSys?.Dispose();
            SettingSys = null;

            L10NService?.Dispose();
            L10NService = null;

            UserService?.Dispose();
            UserService = null;

            InputMgr?.Dispose();
            InputMgr = null;

            SpeechService?.Dispose();
            SpeechService = null;

            Media?.Dispose();
            Media = null;

            OverlayService?.Dispose();
            OverlayService = null;

            lowLatencyTransport?.Close();
            LowLatencyProtocol?.Dispose();
            lowLatencyTransport = null;
            LowLatencyProtocol  = null;

            highLatencyTransport?.Close();
            HighLatencyProtocol?.Dispose();
            HighLatencyProtocol  = null;
            highLatencyTransport = null;

            InstanceCount--;
            if (InstanceCount <= 0)
            {
                factory.SDKCleanup();
            }
        }
예제 #2
0
파일: RuyiSDK.cs 프로젝트: zaga-ruyi/sdk
        /// <summary>
        /// Dispose the SDK instance, don't miss this after SDK usage.
        /// </summary>
        public void Dispose()
        {
            Subscriber?.Dispose();
            Subscriber = null;

            Storage?.Dispose();
            Storage = null;

            RuyiNetService?.Dispose();
            RuyiNetService = null;

            SettingSys?.Dispose();
            SettingSys = null;

            L10NService?.Dispose();
            L10NService = null;

            UserService?.Dispose();
            UserService = null;

            InputMgr?.Dispose();
            InputMgr = null;

            SpeechService?.Dispose();
            SpeechService = null;

            Media?.Dispose();
            Media = null;

            OverlayService?.Dispose();
            OverlayService = null;

            lowLatencyTransport?.Close();
            LowLatencyProtocol?.Dispose();
            lowLatencyTransport = null;
            LowLatencyProtocol  = null;

            highLatencyTransport?.Close();
            HighLatencyProtocol?.Dispose();
            HighLatencyProtocol  = null;
            highLatencyTransport = null;


            // don't clean up netmq in layer0.
            InstanceCount--;
            if (InstanceCount <= 0)
            {
                var entry = Assembly.GetEntryAssembly();
                if (entry == null)  // in a unit test
                {
                    NetMQConfig.Cleanup(false);
                    return;
                }

                // not Layer0 & not Layer1
                if (!entry.FullName.StartsWith("Layer0,", StringComparison.OrdinalIgnoreCase) &&
                    !entry.FullName.StartsWith("zpLayer1,", StringComparison.OrdinalIgnoreCase))
                {
                    NetMQConfig.Cleanup(false);
                    return;
                }
            }
        }