コード例 #1
0
ファイル: SimulationHub.cs プロジェクト: yinondouchan/TDS
        public override System.Threading.Tasks.Task OnDisconnected(bool stopCalled)
        {
            string clientId = GetClientId();

            lock (Users)
            {
                if (Users.IndexOf(clientId) > -1)
                {
                    Users.Remove(clientId);
                }
                if (Users.Count == 0)
                {
                    structQuery2Manager Query2M = new structQuery2Manager();
                    Query2M.QueryStatus = QUERY_SCENARIOSTATUS.QUERY_RETURN_SCENARIO;

                    SessionManager m = (SessionManager)GlobalHost.DependencyResolver.GetService(typeof(SessionManager));
                    m.gameManager.ChangeScenarioStatus(Query2M);

                    //TrackerApplication.TrackerManager trackManager = TrackerApplication.TrackerManager.Instance;
                    //if (trackManager != null)
                    //{
                    //    trackManager.CloseTrackerManager();
                    //}
                }
            }



            return(base.OnDisconnected(stopCalled));
        }
コード例 #2
0
ファイル: SimulationHub.cs プロジェクト: ohadmanor/TDS
        public override System.Threading.Tasks.Task OnDisconnected(bool stopCalled)
        {
            string clientId = GetClientId();

            lock (Users)
            {
                if (Users.IndexOf(clientId) > -1)
                {
                    Users.Remove(clientId);
                }
                if (Users.Count == 0)
                {

                    structQuery2Manager Query2M = new structQuery2Manager();
                    Query2M.QueryStatus = QUERY_SCENARIOSTATUS.QUERY_RETURN_SCENARIO;

                    SessionManager m = (SessionManager)GlobalHost.DependencyResolver.GetService(typeof(SessionManager));
                    m.gameManager.ChangeScenarioStatus(Query2M);

                    //TrackerApplication.TrackerManager trackManager = TrackerApplication.TrackerManager.Instance;
                    //if (trackManager != null)
                    //{
                    //    trackManager.CloseTrackerManager();
                    //}
                }
            }



            return base.OnDisconnected(stopCalled);
        }
コード例 #3
0
ファイル: SimulationHub.cs プロジェクト: yinondouchan/TDS
 public void ChangeScenarioStatus(structQuery2Manager Q2M)
 {
     try
     {
         SessionManager m = (SessionManager)GlobalHost.DependencyResolver.GetService(typeof(SessionManager));
         m.gameManager.ChangeScenarioStatus(Q2M);
     }
     catch (Exception e)
     {
     }
 }
コード例 #4
0
 public void ChangeScenarioStatus(structQuery2Manager Query2M)
 {
     try
     {
         lock (QueryChangeScenarioStatusList)
         {
             int QueryQty = QueryChangeScenarioStatusList.Count;
             if (QueryQty <= 1)
             {
                 QueryChangeScenarioStatusList.Add(Query2M);
             }
             else
             {
                 QueryChangeScenarioStatusList[QueryQty - 1] = Query2M;
             }
             Monitor.Pulse(QueryChangeScenarioStatusList);
         }
     }
     catch { }
 }
コード例 #5
0
ファイル: SimulationHub.cs プロジェクト: ohadmanor/TDS
 public void ChangeScenarioStatus(structQuery2Manager Q2M)
 {
     try
     {
         SessionManager m = (SessionManager)GlobalHost.DependencyResolver.GetService(typeof(SessionManager));
         m.gameManager.ChangeScenarioStatus(Q2M);
        
     }
     catch (Exception e)
     {
     }
 }
コード例 #6
0
        private void StatusController()
        {
            while (StatusControllerThreadShouldStop == false)
            {
                QUERY_SCENARIOSTATUS QUERYob = QUERY_SCENARIOSTATUS.UNDEFINED_STATUS;
                lock (QueryChangeScenarioStatusList)
                {
                    if (QueryChangeScenarioStatusList.Count > 0)
                    {
                        structQuery2Manager Query2M = (structQuery2Manager)QueryChangeScenarioStatusList[0];
                        QUERYob = Query2M.QueryStatus;
                    }
                    else
                    {
                        Monitor.Wait(QueryChangeScenarioStatusList);
                        if (StatusControllerThreadShouldStop)
                        {
                            return;
                        }


                        if (QueryChangeScenarioStatusList.Count > 0)
                        {
                            structQuery2Manager Query2M = (structQuery2Manager)QueryChangeScenarioStatusList[0];
                            QUERYob = Query2M.QueryStatus;
                        }
                    }

                    if (QueryChangeScenarioStatusList.Count > 0)
                    {
                        QueryChangeScenarioStatusList.RemoveAt(0);
                    }
                }
                switch (QUERYob)
                {
                case QUERY_SCENARIOSTATUS.QUERY_START_SCENARIO:
                    if (m_ManagerStatus == typGamestatus.EDIT_STATUS)
                    {
                        InitObjects();

                        m_GameObject.Ex_clockGroundExecute = DateTime.MinValue;

                        ThreadStart worker1 = new ThreadStart(m_GameObject.Ex_Manager);
                        Ex_ManagerThread           = new Thread(worker1);
                        Ex_ManagerThread.Name      = "Ex_Manager";
                        Ex_ManagerThreadShouldStop = false;
                        Ex_ManagerThread.Start();

                        m_ManagerStatus = typGamestatus.RUN_STATUS;
                    }
                    else if (m_ManagerStatus == typGamestatus.PAUSE_STATUS)
                    {
                        if (!Ex_ManagerThread.IsAlive)
                        {
                            ThreadStart worker1 = new ThreadStart(m_GameObject.Ex_Manager);
                            Ex_ManagerThread           = new Thread(worker1);
                            Ex_ManagerThread.Name      = "Ex_Manager";
                            Ex_ManagerThreadShouldStop = false;
                            Ex_ManagerThread.Start();
                        }
                        m_ManagerStatus = typGamestatus.RUN_STATUS;
                    }
                    break;

                case QUERY_SCENARIOSTATUS.QUERY_PAUSE_SCENARIO:
                    if (m_ManagerStatus == typGamestatus.RUN_STATUS)
                    {
                        m_ManagerStatus = typGamestatus.PAUSE_STATUS;
                        //CommonEventArgs arg = new CommonEventArgs();
                        //arg.NTEventCode = enNTEvents.NT_ChangeGamestatus;
                        //arg.ManagerStatus = m_ManagerStatus;
                        //NotifyClientsCommonEvents(arg);
                    }
                    break;

                case QUERY_SCENARIOSTATUS.QUERY_RETURN_SCENARIO:
                {
                    m_ManagerStatus = typGamestatus.PROCESS_RUN2EDIT;

                    //   m_GameObject.IsCancelAllThreads = true;
                    //   Terrain.PathManager.Clear();


                    if (Ex_ManagerThread != null)
                    {
                        if (Ex_ManagerThread.IsAlive)
                        {
                            Ex_ManagerThreadShouldStop = true;
                            Thread.Sleep(20);
                            //  lock (m_GameObject.GroundExecuteStateDelegateLock)
                            {
                                if (m_GameObject.GroundExecuteStateTask != null && m_GameObject.GroundExecuteStateTask.IsCompleted == false)
                                {
                                    try
                                    {
                                        m_GameObject.GroundExecuteStateTask.Wait();
                                    }

                                    catch (AggregateException exx)
                                    {
                                        //  Log.WriteErrorToLog(exx, curScenario.DbName);
                                    }
                                }



                                //if (m_GameObject.DoSynchronizationProcess != null && m_GameObject.DoSynchronizationProcess.IsCompleted == false)
                                //{

                                //    try
                                //    {
                                //        m_GameObject.DoSynchronizationProcess.Wait();
                                //    }

                                //    catch (AggregateException exx)
                                //    {
                                //        Log.WriteErrorToLog(exx, curScenario.DbName);
                                //    }
                                //}
                            }
                            Ex_ManagerThread.Join();
                        }
                    }



                    //Victor 6.06.2012
                    // m_GameObject.ClearAllObjects();



                    // CommonEventArgs arg = new CommonEventArgs();
                    //arg.NTEventCode = enNTEvents.NT_ChangeGamestatus;
                    //arg.ManagerStatus = m_ManagerStatus;
                    //NotifyClientsCommonEvents(arg);



                    // Yinon Douchan: Added code for statistics, not sure it should stay
                    // write collision report before resetting game
                    m_GameObject.writeCollisionReportAndClearData();
                    // -----------------------------------------------------------------

                    InitObjects();

                    m_ManagerStatus = typGamestatus.EDIT_STATUS;



                    NotifyClientsEndCycleArgs args = new NotifyClientsEndCycleArgs();
                    args = new NotifyClientsEndCycleArgs();
                    args.Transport2Client.Ex_clockDate = m_GameObject.Ex_clockDate;
                    // args.Transport2Client.ExClockRatioSpeed = m_GameManager.ExClockRatioSpeed;
                    args.Transport2Client.AtomObjectType       = 2;
                    args.Transport2Client.AtomObjectCollection = m_GameObject.PrepareGroundCommonProperty();
                    args.Transport2Client.ManagerStatus        = ManagerStatus;
                    NotifyClientsEndCycle(args);
                }
                break;
                }
            }
        }
コード例 #7
0
ファイル: GameManager.cs プロジェクト: ohadmanor/TDS
        public void ChangeScenarioStatus(structQuery2Manager Query2M)  
        {
            try
            {
                lock (QueryChangeScenarioStatusList)
                {
                    int QueryQty = QueryChangeScenarioStatusList.Count;
                    if (QueryQty <= 1)
                    {
                        QueryChangeScenarioStatusList.Add(Query2M);
                    }
                    else
                    {
                        QueryChangeScenarioStatusList[QueryQty - 1] = Query2M;

                    }
                    Monitor.Pulse(QueryChangeScenarioStatusList);
                }
               
            }
            catch { }
        }