예제 #1
0
        /// start the session
        public void StartSession()
        {
            FTasksManager    = new TClientTasksManager();
            FPollClientTasks = new TPollClientTasks(FTasksManager);

            FClientConnectionStartTime = DateTime.Now;

            SessionStatus = TSessionStatus.adsActive;
            FClientConnectionFinishedTime = DateTime.Now;
        }
예제 #2
0
        /// start the session
        public void StartSession(TDelegateTearDownAppDomain ATearDownAppDomain)
        {
            FTasksManager    = new TClientTasksManager();
            FPollClientTasks = new TPollClientTasks(FTasksManager);

            FClientConnectionStartTime = DateTime.Now;

            // Start ClientStillAliveCheck Thread
            new ClientStillAliveCheck.TClientStillAliveCheck(this, FClientServerConnectionType, ATearDownAppDomain);

            SessionStatus = TSessionStatus.adsActive;
            FClientConnectionFinishedTime = DateTime.Now;
        }
예제 #3
0
        /// start the session
        public void StartSession(TDelegateTearDownAppDomain ATearDownAppDomain)
        {
            FTasksManager = new TClientTasksManager();
            FPollClientTasks = new TPollClientTasks(FTasksManager);

            FClientConnectionStartTime = DateTime.Now;

            // Start ClientStillAliveCheck Thread
            new ClientStillAliveCheck.TClientStillAliveCheck(this, FClientServerConnectionType, ATearDownAppDomain);

            SessionStatus = TSessionStatus.adsActive;
            FClientConnectionFinishedTime = DateTime.Now;
        }
예제 #4
0
            /**
             * Thread that checks in regular intervals whether the Date and Time when the
             * last Client call to 'PollClientTasks' was made exceeds a certain timeout
             * limit (different for Clients connected via LAN or Remote).
             *
             * @comment The Thread is started at Class instantiation and can be stopped by
             * calling the StopClientStillAliveCheckThread method.
             *
             * @comment The check interval can be configured with the ServerSetting
             * 'Server.ClientKeepAliveCheckIntervalInSeconds'.
             *
             */
            public void ClientStillAliveCheckThread()
            {
                TimeSpan Duration;
                DateTime LastPollingTime;

                // Check whether this Thread should still execute
                while (UKeepServerAliveCheck)
                {
                    if (TLogging.DL >= 10)
                    {
                        Console.WriteLine("{0} TClientStillAliveCheck: ClientStillAliveCheckThread: checking...", DateTime.Now);
                    }

                    // Get the time of the last call to TPollClientTasks.PollClientTasks
                    LastPollingTime = TPollClientTasks.GetLastPollingTime();

                    // Calculate time between the last call to TPollClientTasks.PollClientTasks and now
                    Duration = DateTime.Now.Subtract(LastPollingTime);

                    // Determine whether the timeout has been exceeded
                    if (Duration.TotalSeconds < UClientStillAliveTimeout)
                    {
                        // No it hasn't
                        if (TLogging.DL >= 10)
                        {
                            Console.WriteLine("{0} TClientStillAliveCheck: ClientStillAliveCheckThread: timeout hasn't been exceeded.", DateTime.Now);
                        }

                        try
                        {
                            // Sleep for some time. After that, this procedure is called again automatically.
                            if (TLogging.DL >= 10)
                            {
                                Console.WriteLine("{0} TClientStillAliveCheck: ClientStillAliveCheckThread: going to sleep...", DateTime.Now);
                            }

                            Thread.Sleep(UClientStillAliveCheckInterval * 1000);

                            if (TLogging.DL >= 10)
                            {
                                Console.WriteLine("{0} TClientStillAliveCheck: ClientStillAliveCheckThread: re-awakening...", DateTime.Now);
                            }
                        }
                        catch (ThreadAbortException)
                        {
                            if (TLogging.DL >= 10)
                            {
                                Console.WriteLine("{0} TClientStillAliveCheck: ClientStillAliveCheckThread: ThreadAbortException occured!!!",
                                                  DateTime.Now);
                            }

                            UKeepServerAliveCheck = false;
                        }
                    }
                    else
                    {
                        if (TLogging.DL >= 5)
                        {
                            Console.WriteLine(
                                "{0} TClientStillAliveCheck: ClientStillAliveCheckThread: timeout HAS been exceeded (last PollClientTasks call: " +
                                LastPollingTime.ToString() + ") -> SignalTearDownAppDomain!",
                                DateTime.Now);
                        }

                        /*
                         * Timeout has been exceeded, this means the Client didn't make a call
                         * to TPollClientTasks.PollClientTasks within the time that is specified
                         * in UClientStillAliveTimeout
                         */

                        /*
                         * KeepServerAliveCheck Thread should no longer run (has an effect only
                         * when this procedure is called from the ClientStillAliveCheckThread
                         * Thread itself)
                         */
                        UKeepServerAliveCheck = false;

                        if (UTearDownAppDomain != null)
                        {
                            UTearDownAppDomain(UTearDownAppDomainToken,
                                               String.Format(StrClientFailedToContact, Duration.Hours.ToString() + ':' + Duration.Minutes.ToString() + ':' +
                                                             Duration.Seconds.ToString()));
                        }
                        else
                        {
                            if (TLogging.DL >= 10)
                            {
                                Console.WriteLine(
                                    "{0} TClientStillAliveCheck: FTearDownAppDomain was not assigned -> can't tear down Client's AppDomain!",
                                    DateTime.Now);
                            }
                        }
                    }
                }

                // Thread stops here and doesn't get called again automatically.
                if (TLogging.DL >= 10)
                {
                    Console.WriteLine("{0} TClientStillAliveCheck: ClientStillAliveCheckThread: Thread stopped!", DateTime.Now);
                }
            }