public void Start()
        {
            _bKeepRunning = true;
            sockServer    = new SocketPackage();

            sockServer.OnClientConnected    += new ClientConnectedHandler(sockServer_OnClientConnected);
            sockServer.OnRequestReceived    += new MessageReceivedHandler(sockServer_OnRequestReceived);
            sockServer.OnClientDisconnected += new ClientDisconnectedHandler(sockServer_OnClientDisconnected);
            sockServer.StartListen(ListenPortNumber);

            myThread      = new Thread(new ThreadStart(MonitorClient));
            myThread.Name = myThreadName;
            myThread.Start();
        }
Example #2
0
        public void IniciarServico()
        {
            _bKeepRunning = true;
            logger.Info("Iniciando servico SpreadMonitor");

            //Obtendo configuracoes
            // Obtem o timeout de mensagem com o MDS, em segundos
            TimeoutMDS = 300;
            if (ConfigurationManager.AppSettings["TimeoutMDS"] != null)
            {
                TimeoutMDS = Convert.ToDouble(ConfigurationManager.AppSettings["TimeoutMDS"].ToString());
            }
            TimeoutMDS *= 1000;

            // Inicia o gerenciador das threads
            ThreadPoolManager.Instance.Start();

            // Carregar algos do DB
            PersistenciaDB    db    = new PersistenciaDB();
            List <AlgoStruct> algos = db.CarregarAlgoritmos();

            foreach (AlgoStruct algo in algos)
            {
                ThreadPoolManager.Instance.AddAlgoritmo(algo);
            }

            // Conectar ao MDS
            thMonitorMds = new Thread(new ThreadStart(this.MonitorConexaoMDS));
            thMonitorMds.Start();

            // Aguardar conexoes do streamer
            int streamerPort = 6565;

            if (ConfigurationManager.AppSettings["StreamerListenPort"] != null)
            {
                streamerPort = Convert.ToInt32(ConfigurationManager.AppSettings["StreamerListenPort"].ToString());
            }

            //
            _sockServer = new SocketPackage();
            _sockServer.StartListen(streamerPort);

            //_sockServer.
        }