示例#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>
 /// Basic update loop.
 /// </summary>
 public void Update()
 {
     RuyiNetService.Update();
 }
示例#3
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;
                }
            }
        }