Esempio n. 1
0
        private static bool UnregisterEventHandlers(AudioEngine_srv i_amSrv)
        {
            bool bRet = true;

            ISMessaging.Delivery.ISMDistributer.ISMDistributerEventHandler deh = new ISMessaging.Delivery.ISMDistributer.ISMDistributerEventHandler(i_amSrv.NewMsg);
            AMEvHook.MsgDistr.ISMMsg -= deh;

            return(bRet);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            bool            bRes = true;
            string          sPrompt = "> ", sCmd = "", sLogPath = "";
            AudioEngine_srv amSrv = null;
            ILegacyLogger   logger = null;
            string          sDisableKeyboard = "", sVer = "";
            AssemblyName    asmName = null;

            //Name the main thread
            Thread.CurrentThread.Name = "AudioMgrMainT";

            // Set up the logger(s)
            sLogPath = ConfigurationManager.AppSettings[cs_LogFilePath];
            if (!(sLogPath.EndsWith("/") || sLogPath.EndsWith("\\")))
            {
                sLogPath = sLogPath + "/";
            }
            logger = new LegacyLogger();
            logger.Init("", "", Thread.CurrentThread.Name, "", "", sLogPath);
            bRes = logger.Open();
            if (!bRes)
            {
                Console.Error.WriteLine("AudioMgr failed to open the logger!");
            }
            else
            {
                asmName = Assembly.GetAssembly(typeof(AudioMgr.AudioEngine)).GetName();
                sVer    = asmName.Version.ToString();
                logger.Log(Level.Info, "AudioMgr v" + sVer);

                bRes = RemotingConfig(logger);

                amSrv = new AudioEngine_srv(logger);
                bRes  = RegisterEventHandlers(amSrv);

                if (!bRes)
                {
                    logger.Log(Level.Exception, " AudioMgr failed registering event handlers!");
                }
                else
                {
                    bRes = amSrv.LoadASR(logger);
                    if (!bRes)
                    {
                        logger.Log(Level.Exception, " AudioMgr failed to load ASR(s)!");
                    }
                    else
                    {
                        bRes = amSrv.CreateWorkerThreads(sLogPath);
                        if (!bRes)
                        {
                            logger.Log(Level.Exception, " AudioMgr failed to create worker threads!");
                        }
                        else
                        {
                            //Console.WriteLine("AudioMgr startup successful.");
                            logger.Log(Level.Info, "AudioMgr startup successful.");

                            sDisableKeyboard = ConfigurationManager.AppSettings[cs_DisableKeyboard];
                            sDisableKeyboard = (sDisableKeyboard == null) ? "" : sDisableKeyboard;
                            if (sDisableKeyboard == "false")
                            {
                                Console.Write(sPrompt);
                                sCmd = Console.ReadLine();
                                while (bRes)
                                {
                                    bRes = amSrv.ProcessCmdString(sCmd);
                                    if (bRes)
                                    {
                                        Console.Write(sPrompt);
                                        sCmd = Console.ReadLine();
                                    }
                                }
                            }

                            // Join worker threads before exiting
                            amSrv.JoinWorkerThreads();

                            UnregisterEventHandlers(amSrv);
                        }
                    }
                }

                logger.Log(Level.Info, "AudioMgr shutdown.");
                logger.Close();
            }
        }