Example #1
0
        protected override void OnStart(string[] args)
        {
            var    appSettings     = ConfigurationManager.AppSettings;
            var    LogFlags        = ConfigurationManager.GetSection("LogFlags") as NameValueCollection;
            string debugFilename   = @"C:\cygwin64\home\listdog\logs\ort_debug.txt";
            string sessionFilename = @"C:\cygwin64\home\listdog\logs\ort_session.txt";

            if (LogFlags != null)
            {
                if (LogFlags["LogDebug"] != null &&
                    string.Compare(LogFlags["LogDebug"].ToString(), "1", true) == 0)
                {
                    ORTLog.EnableDebug = true;
                }

                if (LogFlags["LogSession"] != null &&
                    string.Compare(LogFlags["LogSession"].ToString(), "1", true) == 0)
                {
                    ORTLog.EnableSession = true;
                }

                if (LogFlags["DebugFilename"] != null)
                {
                    debugFilename = LogFlags["DebugFilename"].ToString();
                }

                if (LogFlags["SessionFilename"] != null)
                {
                    sessionFilename = LogFlags["SessionFilename"].ToString();
                }
            }

            ORTLog.Open(debugFilename, sessionFilename);

            var TcpFlags          = ConfigurationManager.GetSection("LogFlags") as NameValueCollection;
            int deviceServerPort  = 3333;
            int commandServerPort = 8888;

            if (TcpFlags != null)
            {
                if (TcpFlags["ORTDeviceServerPort"] != null)
                {
                    deviceServerPort = int.Parse(TcpFlags["ORTDeviceServerPort"].ToString());
                }

                if (TcpFlags["ORTCommandServerPort"] != null)
                {
                    commandServerPort = int.Parse(TcpFlags["ORTCommandServerPort"].ToString());
                }
            }

            ORTLog.LogD("Service Started");

            m_deviceServer = new DeviceServer(IPAddress.Any, deviceServerPort);
            m_deviceServer.StartServer();

            m_commandServer = new CommandServer(IPAddress.Any, commandServerPort);
            m_commandServer.StartServer();
        }
Example #2
0
        protected override void OnStop()
        {
            m_deviceServer.StopServer();
            m_deviceServer = null;

            m_commandServer.StopServer();
            m_commandServer = null;

            ORTLog.LogD("Service Stopped");
            ORTLog.Close();
        }