Exemplo n.º 1
0
        protected override void OnTick()
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

            if (m_LastElapsedTickTime != 0)
            {
                long elapsedTickTime = curTime - m_LastElapsedTickTime;
                if (elapsedTickTime > c_WarningTickTime)
                {
                    LogSys.Log(LOG_TYPE.MONITOR, "DbThread Tick:{0} {1}", this.Thread.ManagedThreadId, elapsedTickTime);
                }
            }
            m_LastElapsedTickTime = curTime;

            if (DataCacheConfig.IsPersistent)
            {
                if (m_LastTickTime + c_TickInterval < curTime)
                {
                    m_LastTickTime = curTime;

                    DBConn.KeepConnection();
                    try {
                        MySqlConnection conn = DBConn.MySqlConn;
                        using (MySqlCommand cmd = new MySqlCommand("select * from DSNodeInfo where 1=2", conn)) {
                            cmd.ExecuteNonQuery();
                        }
                    } catch (Exception ex) {
                        LogSys.Log(LOG_TYPE.ERROR, "DbThread.Tick keep connection exception:{0}\n{1}", ex.Message, ex.StackTrace);
                    }
                }
            }

            if (m_LastLogTime + 60000 < curTime)
            {
                m_LastLogTime = curTime;

                DebugPoolCount((string msg) => {
                    LogSys.Log(LOG_TYPE.INFO, "DbThread.ActionQueue {0} {1}", this.Thread.ManagedThreadId, msg);
                });
                LogSys.Log(LOG_TYPE.MONITOR, "DbThread.ActionQueue Current Action {0} {1}", this.Thread.ManagedThreadId, this.CurActionNum);
            }
        }
Exemplo n.º 2
0
        private bool TryInitImpactInfo(ImpactInfo impactInfo, TableConfig.Skill cfg, int seq, int curObjId, int srcObjId, Dictionary <string, object> args)
        {
            bool       ret    = false;
            EntityInfo srcNpc = m_Scene.EntityManager.GetEntityInfo(srcObjId);

            impactInfo.StartTime      = TimeUtility.GetLocalMilliseconds();
            impactInfo.ImpactSenderId = srcObjId;
            if (cfg.type == (int)SkillOrImpactType.Skill)
            {
                impactInfo.SenderPosition = null != srcNpc?srcNpc.GetMovementStateInfo().GetPosition3D() : ScriptRuntime.Vector3.Zero;

                impactInfo.SkillId      = cfg.id;
                impactInfo.DurationTime = cfg.duration > 0 ? cfg.duration : impactInfo.ConfigData.duration;
                impactInfo.TargetType   = cfg.targetType;
                impactInfo.DamageData.CopyFrom(cfg.damageData);
                impactInfo.DamageData.Merge(impactInfo.ConfigData.damageData);
                impactInfo.ImpactToTarget = cfg.impact;
                ret = true;
            }
            else
            {
                ImpactInfo srcImpactInfo = null;
                EntityInfo curObj        = m_Scene.EntityManager.GetEntityInfo(curObjId);
                if (null != curObj)
                {
                    srcImpactInfo = curObj.GetSkillStateInfo().GetImpactInfoBySeq(seq);
                }
                if (null != srcImpactInfo)
                {
                    //如果当前技能配置有数据则继承当前配置数据,否则继承源impact记录的数据。
                    impactInfo.SenderPosition = srcImpactInfo.SenderPosition;
                    impactInfo.SkillId        = srcImpactInfo.SkillId;
                    impactInfo.DurationTime   = srcImpactInfo.DurationTime > 0 ? srcImpactInfo.DurationTime : impactInfo.ConfigData.duration;
                    impactInfo.TargetType     = srcImpactInfo.TargetType;
                    impactInfo.DamageData.CopyFrom(srcImpactInfo.DamageData);
                    impactInfo.DamageData.Merge(impactInfo.ConfigData.damageData);
                    impactInfo.ImpactToTarget = cfg.impact != 0 ? cfg.impact : srcImpactInfo.ImpactToTarget;
                    ret = true;
                }
            }
            return(ret);
        }
Exemplo n.º 3
0
 public void Tick()
 {
     if (0 == m_LastTickTime)
     {
         m_LastTickTime = TimeUtility.GetLocalMilliseconds();
     }
     else
     {
         long delta = TimeUtility.GetLocalMilliseconds() - m_LastTickTime;
         m_LastTickTime = TimeUtility.GetLocalMilliseconds();
         if (null != m_NpcMgr)
         {
             for (LinkedListNode <EntityInfo> linkNode = m_NpcMgr.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next)
             {
                 EntityInfo entity = linkNode.Value;
                 TickNpc(entity, delta);
             }
         }
     }
 }
Exemplo n.º 4
0
            internal void Log(string format, params object[] args)
            {
                if (!m_Enabled)
                {
                    return;
                }
                string msg = DateTime.Now.ToString("HH-mm-ss-fff:") + string.Format(format, args);

#if USE_DISK_LOG
                m_LogStream.WriteLine(msg);
                m_LogStream.Flush();
#else
                m_LogQueue.Enqueue(msg);
                if (!m_IsInRequestFlush && m_LogQueue.Count >= c_FlushCount)
                {
                    m_LastFlushTime = TimeUtility.GetLocalMilliseconds();

                    RequestFlush();
                }
#endif
            }
Exemplo n.º 5
0
        internal void RequestLoad(Msg_LD_Load msg, MyAction <Msg_DL_LoadResult> callback)
        {
            msg.SerialNo = GenNextSerialNo();
            KeyString key = KeyString.Wrap(msg.PrimaryKeys);
            ConcurrentDictionary <KeyString, LoadRequestInfo> dict = null;

            if (!m_LoadRequests.TryGetValue(msg.MsgId, out dict))
            {
                dict = m_LoadRequests.AddOrUpdate(msg.MsgId, new ConcurrentDictionary <KeyString, LoadRequestInfo>(), (k, v) => v);
            }
            LoadRequestInfo info;

            if (!dict.TryGetValue(key, out info))
            {
                info = dict.AddOrUpdate(key, m_LoadRequestPool.Alloc(), (k, v) => v);
            }
            info.m_LastSendTime = TimeUtility.GetLocalMilliseconds();
            info.m_Request      = msg;
            info.m_Callback     = callback;
            m_DataStoreChannel.Send(msg);
        }
Exemplo n.º 6
0
 public void Tick()
 {
     if (null == m_SceneLogicInfoMgr)
     {
         return;
     }
     if (0 == m_LastTickTime)
     {
         m_LastTickTime = TimeUtility.GetLocalMilliseconds();
     }
     else
     {
         long delta = TimeUtility.GetLocalMilliseconds() - m_LastTickTime;
         m_LastTickTime = TimeUtility.GetLocalMilliseconds();
         for (LinkedListNode <SceneLogicInfo> node = m_SceneLogicInfoMgr.SceneLogicInfos.FirstNode; null != node; node = node.Next)
         {
             SceneLogicInfo info = node.Value;
             if (null != info)
             {
                 ISceneLogic logic = SceneLogicManager.Instance.GetSceneLogic(info.LogicId);
                 if (null != logic)
                 {
                     logic.Execute(info, delta);
                 }
                 if (info.IsLogicFinished)
                 {
                     m_SceneLogicInfos.Add(info);
                 }
             }
         }
         for (int i = 0; i < m_SceneLogicInfos.Count; i++)
         {
             m_SceneLogicInfoMgr.RemoveSceneLogicInfo(m_SceneLogicInfos[i].GetId());
         }
         m_SceneLogicInfos.Clear();
         m_SceneLogicInfoMgr.ExecuteDelayAdd();
     }
 }
Exemplo n.º 7
0
 public bool Init(int room_id, int scene_type, UserPool userpool, Connector conn)
 {
     LogSys.Log(LOG_TYPE.INFO, "[0] Room.Init {0} scene {1}", room_id, scene_type);
     m_RoomId                  = room_id;
     m_UserPool                = userpool;
     m_Connector               = conn;
     m_CanCloseTime            = 0;
     m_RoomUserMgr.Connector   = conn;
     m_RoomUserMgr.RoomId      = room_id;
     m_RoomUserMgr.LocalRoomId = (int)m_LocalID;
     m_RoomUserMgr.UserPool    = userpool;
     m_RoomUserMgr.ActiveScene = m_ScenePool.NewScene();
     LogSys.Log(LOG_TYPE.INFO, "[1] Room.Init {0} scene {1}", room_id, scene_type);
     m_RoomUserMgr.ActiveScene.SetRoomUserManager(m_RoomUserMgr);
     m_RoomUserMgr.ActiveScene.Init(scene_type);
     //场景数据加载由加载线程执行(注:场景没有加载完成,场景状态仍然是sleep,Scene.Tick不会有实际的动作)
     SceneLoadThread.Instance.QueueAction(m_RoomUserMgr.ActiveScene.LoadData, scene_type);
     OnInit();
     m_ActiveTime = TimeUtility.GetLocalMicroseconds();
     CurrentState = RoomState.Active;
     m_CanFinish  = false;
     LogSys.Log(LOG_TYPE.DEBUG, "Room Initialize: {0}  Scene: {1}", room_id, scene_type);
     return(true);
 }
Exemplo n.º 8
0
        internal bool VerifyMovingPosition(float x, float z, float velocity)
        {
            bool ret = true;

            if (m_LastSampleTime > 0)
            {
                long    time          = TimeUtility.GetLocalMilliseconds();
                Vector3 pos           = new Vector3(x, 0, z);
                float   distSqr       = Geometry.DistanceSquare(pos, m_LastClientPosition);
                float   v             = Geometry.Max(velocity, m_LastMoveVelocity);
                float   t             = (time - m_LastSampleTime) / 1000.0f;
                float   enableDist    = v * t;
                float   enableDistSqr = enableDist * enableDist;
                if (distSqr > 1 && (distSqr > enableDistSqr * 2 + 1 /* || distSqr < enableDistSqr / 2 - 1*/))
                {
                    ret = false;
                    float sx = m_LastClientPosition.X + enableDist * m_LastMoveDirSinAngle;
                    float sz = m_LastClientPosition.Z + enableDist * m_LastMoveDirCosAngle;

                    LogSys.Log(LOG_TYPE.ERROR, "VerifyMoveData user:{0}({1},{2},{3}) t:{4} v:{5} x:{6} z:{7} sx:{8} sz:{9} distSqr:{10} enableDistSqr:{11}", RoleId, GetKey(), Guid, Name, t, v, x, z, sx, sz, distSqr, enableDistSqr);
                }
            }
            return(ret);
        }
Exemplo n.º 9
0
        public void RetireAttackerInfos(long lifetime)
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

            if (m_LastRetireTime + lifetime < curTime)
            {
                m_LastRetireTime = curTime;

                m_WaitDeleteAttackers.Clear();
                foreach (var pair in AttackerInfos)
                {
                    AttackerInfo info = pair.Value;
                    if (info.m_AttackTime + lifetime < curTime || m_SceneContext.GetEntityById(pair.Key) == null)
                    {
                        m_WaitDeleteAttackers.Add(pair.Key);
                    }
                }
                for (int i = 0; i < m_WaitDeleteAttackers.Count; ++i)
                {
                    AttackerInfos.Remove(m_WaitDeleteAttackers[i]);
                }
                m_WaitDeleteAttackers.Clear();
            }
        }
        public bool LoadFromBinary(string file)
        {
            long        t1     = TimeUtility.GetElapsedTimeUs();
            bool        result = true;
            BinaryTable table  = new BinaryTable();

            table.Load(HomePath.GetAbsolutePath(file));
            long t2 = TimeUtility.GetElapsedTimeUs();

            long t3 = TimeUtility.GetElapsedTimeUs();

            for (int index = 0; index < table.Records.Count; ++index)
            {
                try {
                    TData data = new TData();
                    bool  ret  = data.ReadFromBinary(table, index);
                    if (ret && !m_DataContainer.ContainsKey(data.GetId()))
                    {
                        m_DataContainer.Add(data.GetId(), data);
                    }
                    else
                    {
                        string info = string.Format("DataTempalteMgr.CollectDataFromBinary collectData Row:{0} failed in {1}!", index, file);
                        LogSystem.Error(info);
                        Helper.LogCallStack(true);
                        result = false;
                    }
                } catch (System.Exception ex) {
                    LogSystem.Error("CollectData failed. file:{0} rowIndex:{1}\nException:{2}\n{3}", file, index, ex.Message, ex.StackTrace);
                }
            }
            long t4 = TimeUtility.GetElapsedTimeUs();

            LogSystem.Info("binary load {0} parse {1}, file {2}", t2 - t1, t4 - t3, file);
            return(result);
        }
Exemplo n.º 11
0
 public void Init(NetConnection conn)
 {
     m_EnterRoomTime = TimeUtility.GetLocalMilliseconds();
     m_Connection    = conn;
 }
Exemplo n.º 12
0
 public void Start()
 {
     game_start_ms_ = TimeUtility.GetLocalMilliseconds();
 }
Exemplo n.º 13
0
        private void OnTick()
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

            if (m_LastTickTime != 0)
            {
                long elapsedTickTime = curTime - m_LastTickTime;
                if (elapsedTickTime > c_WarningTickTime)
                {
                    LogSys.Log(LOG_TYPE.MONITOR, "DataCacheThread Tick:{0}", elapsedTickTime);
                }
            }
            m_LastTickTime = curTime;

            if (m_LastLogTime + 60000 < curTime)
            {
                m_LastLogTime = curTime;
                DebugPoolCount((string msg) => {
                    LogSys.Log(LOG_TYPE.INFO, "DataCacheThread.DispatchActionQueue {0}", msg);
                });
                DebugActionCount((string msg) => {
                    LogSys.Log(LOG_TYPE.MONITOR, "DataCacheThread.DispatchActionQueue {0}", msg);
                });
                LogSys.Log(LOG_TYPE.MONITOR, "DataCacheThread.ThreadActionQueue Current Action {0}", m_Thread.CurActionNum);
                LogSys.Log(LOG_TYPE.MONITOR, "DataCacheThread Load Request Count {0} Save Request Count {1}", CalcLoadRequestCount(), CalcSaveRequestCount());
            }
            if (UserServerConfig.DataStoreAvailable == true)
            {
                if (m_LastOperateTickTime + c_OperateTickInterval < curTime)
                {
                    m_LastOperateTickTime = curTime;
                    //Load操作
                    foreach (var pair in m_LoadRequests)
                    {
                        int msgId = pair.Key;
                        ConcurrentDictionary <KeyString, LoadRequestInfo> dict = pair.Value;
                        foreach (var reqPair in dict)
                        {
                            KeyString       primaryKey = reqPair.Key;
                            LoadRequestInfo req        = reqPair.Value;
                            if (req.m_LastSendTime + UserServerConfig.DSRequestTimeout < curTime)
                            {
                                m_WaitDeletedLoadRequests.Add(primaryKey, req.m_Request.SerialNo);
                                Msg_DL_LoadResult result = new Msg_DL_LoadResult();
                                result.MsgId = msgId;
                                result.PrimaryKeys.AddRange(primaryKey.Keys);
                                result.SerialNo  = req.m_Request.SerialNo;
                                result.ErrorNo   = Msg_DL_LoadResult.ErrorNoEnum.TimeoutError;
                                result.ErrorInfo = "Timeout Error";
                                if (null != req.m_Callback)
                                {
                                    DispatchAction(req.m_Callback, result);
                                }
                            }
                        }
                        foreach (var delPair in m_WaitDeletedLoadRequests)
                        {
                            LoadRequestInfo info;
                            if (dict.TryRemove(delPair.Key, out info))
                            {
                                if (info.m_Request.SerialNo == delPair.Value)
                                {
                                    m_LoadRequestPool.Recycle(info);
                                }
                                else
                                {
                                    dict.TryAdd(delPair.Key, info);
                                }
                            }
                        }
                        m_WaitDeletedLoadRequests.Clear();
                    }
                    //Save操作
                    foreach (var pair in m_SaveRequestQueues)
                    {
                        int msgId = pair.Key;
                        ConcurrentDictionary <KeyString, ConcurrentQueue <SaveRequestInfo> > dict = pair.Value;
                        foreach (var reqPair in dict)
                        {
                            KeyString primaryKey = reqPair.Key;
                            ConcurrentQueue <SaveRequestInfo> saveReqQueue = reqPair.Value;
                            SaveRequestInfo req;
                            if (saveReqQueue.TryPeek(out req))
                            {
                                if (req.m_LastSendTime + UserServerConfig.DSRequestTimeout < curTime)
                                {
                                    //超时,重新发送
                                    LogSys.Log(LOG_TYPE.ERROR, "DataCacheThread. SaveRequest timeout. MsgId:{0}, PrimaryKey:{1}, SerialNo:{2}",
                                               msgId, KeyString.Wrap(req.m_Request.PrimaryKeys), req.m_Request.SerialNo);
                                    m_DataStoreChannel.Send(req.m_Request);
                                    req.m_LastSendTime = curTime;
                                }
                            }
                            if (dict.Count > c_MaxRecordPerMessage && saveReqQueue.Count == 0)
                            {
                                m_WaitDeleteSaveRequests.Add(primaryKey);
                            }
                        }
                        foreach (KeyString key in m_WaitDeleteSaveRequests)
                        {
                            lock (m_SaveRequestQueuesLock) {
                                ConcurrentQueue <SaveRequestInfo> queue;
                                if (dict.TryGetValue(key, out queue))
                                {
                                    if (queue.Count == 0)
                                    {
                                        ConcurrentQueue <SaveRequestInfo> dummy;
                                        dict.TryRemove(key, out dummy);
                                    }
                                }
                            }
                        }
                        m_WaitDeleteSaveRequests.Clear();
                    }
                }
                if (m_LastDSConnectTime + c_DSConnectInterval < curTime)
                {
                    m_LastDSConnectTime = curTime;
                    if (m_CurrentStatus != ConnectStatus.Connected)
                    {
                        ConnectDataStore();
                    }
                }
            }
        }
Exemplo n.º 14
0
        internal bool AddNewUser(User newUser)
        {
            foreach (User us in room_users_)
            {
                if (us != null && us.Guid == newUser.Guid)
                {
                    //当前玩家已在游戏房间内
                    if (us.GetKey() == newUser.GetKey())
                    {
                        LogSys.Log(LOG_TYPE.DEBUG, "Add user success: User already in the room! RoomID:{0}, Guid:{1}, OldUser[{2}]({3}) NewUser[{4}]({5}) ",
                                   cur_room_id_, us.Guid, us.LocalID, us.GetKey(), newUser.LocalID, newUser.GetKey());
                        LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for new {1} {2}, [Room.AddNewUser]", newUser.LocalID, newUser.Guid, newUser.GetKey());
                        user_pool_.FreeUser(newUser.LocalID);
                        return(true);
                    }
                    else if (us.UserControlState != (int)UserControlState.User)
                    {
                        LogSys.Log(LOG_TYPE.DEBUG, "Add user success: User already in the room! RoomID:{0}, Guid:{1}, OldUser[{2}]({3}) NewUser[{4}]({5}) ",
                                   cur_room_id_, us.Guid, us.LocalID, us.GetKey(), newUser.LocalID, newUser.GetKey());
                        LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for old {1} {2}, [Room.AddNewUser]", us.LocalID, us.Guid, us.GetKey());
                        RemoveUser(us);
                        break;
                    }
                    else
                    {
                        LogSys.Log(LOG_TYPE.DEBUG, "Add user false: User already in the room and online! RoomID:{0}, Guid:{1}, OldUser[{2}]({3}) NewUser[{4}]({5}) ",
                                   cur_room_id_, us.Guid, us.LocalID, us.GetKey(), newUser.LocalID, newUser.GetKey());
                        LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for new {1} {2}, [Room.AddNewUser]", newUser.LocalID, newUser.Guid, newUser.GetKey());
                        user_pool_.FreeUser(newUser.LocalID);
                        return(false);
                    }
                }
            }
            can_close_time_       = 0;
            newUser.EnterRoomTime = TimeUtility.GetLocalMilliseconds();
            newUser.OwnRoom       = this;
            newUser.RegisterObservers(room_observers_);
            newUser.CharacterCreateTime = TimeUtility.GetLocalMilliseconds();
            newUser.TimeCounter         = 0;
            if ((int)UserControlState.Ai == newUser.UserControlState)
            {
                newUser.IsEntered = true;
            }
            if (null != m_ActiveScene && m_ActiveScene.SceneState == SceneState.Running)
            {
                Scene scene = m_ActiveScene;
                scene.EnterScene(newUser);
            }
            foreach (User otheruser in room_users_)
            {
                if (otheruser != null)
                {
                    otheruser.AddSameRoomUser(newUser);
                    newUser.AddSameRoomUser(otheruser);
                }
            }
            room_users_.Add(newUser);
            LogSys.Log(LOG_TYPE.DEBUG, "Add user success ! RoomID:{0} , UserGuid:{1}({2})",
                       cur_room_id_, newUser.Guid, newUser.GetKey());

            m_CanFinish = true;
            return(true);
        }
Exemplo n.º 15
0
 private long End_()
 {
     m_EndTime = TimeUtility.GetElapsedTimeUs();
     return(m_EndTime - m_StartTime);
 }
Exemplo n.º 16
0
        private void TickRunning()
        {
            TimeSnapshot.DoCheckPoint();

            m_KdTree.BeginBuild(m_EntityMgr.Entities.Count);
            for (LinkedListNode <EntityInfo> linkNode = m_EntityMgr.Entities.FirstNode; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                m_KdTree.AddObjForBuild(info);
            }
            m_KdTree.EndBuild();

            m_ServerDelayActionProcessor.HandleActions(100);
            m_SceneProfiler.DelayActionProcessorTime = TimeSnapshot.DoCheckPoint();

            m_MovementSystem.Tick();
            m_SceneProfiler.MovementSystemTime = TimeSnapshot.DoCheckPoint();

            TickAi();
            m_SceneProfiler.AiSystemTime = TimeSnapshot.DoCheckPoint();

            m_SceneLogicSystem.Tick();
            m_SceneProfiler.SceneLogicSystemTime = TimeSnapshot.DoCheckPoint();

            m_StorySystem.Tick();
            m_GmStorySystem.Tick();
            m_SceneProfiler.StorySystemTime = TimeSnapshot.DoCheckPoint();

            TickEntities();
            m_SceneProfiler.TickEntitiesTime = TimeSnapshot.DoCheckPoint();

            //属性同步
            if (0 == m_LastTickTimeForTickPerSecond)
            {
                m_LastTickTimeForTickPerSecond = TimeUtility.GetLocalMilliseconds();
                TickProperty();
            }
            else
            {
                long curTime = TimeUtility.GetLocalMilliseconds();
                if (curTime > m_LastTickTimeForTickPerSecond + c_IntervalPerSecond)
                {
                    m_LastTickTimeForTickPerSecond = curTime;
                    TickProperty();
                }
            }

            if (0 == m_LastTickTimeForTickPer5s)
            {
                m_LastTickTimeForTickPer5s = TimeUtility.GetLocalMilliseconds();
                ReloadObjects();
            }
            else
            {
                long curTime = TimeUtility.GetLocalMilliseconds();
                if (curTime > m_LastTickTimeForTickPer5s + c_IntervalPer5s)
                {
                    m_LastTickTimeForTickPer5s = curTime;
                    ReloadObjects();
                }
            }

            m_SceneProfiler.TickAttrRecoverTime = TimeSnapshot.DoCheckPoint();
            //空间信息调试
            TickDebugSpaceInfo();
            m_SceneProfiler.TickDebugSpaceInfoTime = TimeSnapshot.DoCheckPoint();
        }
Exemplo n.º 17
0
        protected override void OnTick()
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

            if (m_LastTickTime != 0)
            {
                long elapsedTickTime = curTime - m_LastTickTime;
                if (elapsedTickTime > c_WarningTickTime)
                {
                    LogSys.Log(LOG_TYPE.MONITOR, "GlobalProcessThread Tick:{0}", elapsedTickTime);
                }
            }
            m_LastTickTime = curTime;
            if (m_LastLogTime + 60000 < curTime)
            {
                m_LastLogTime = curTime;

                DebugPoolCount((string msg) => {
                    LogSys.Log(LOG_TYPE.INFO, "GlobalProcessThread.ActionQueue {0}", msg);
                });
                LogSys.Log(LOG_TYPE.MONITOR, "GlobalProcessThread.ActionQueue Current Action {0}", this.CurActionNum);
            }
            //逻辑Tick
            GlobalData.Instance.Tick();
            UserServer.Instance.UserProcessScheduler.NicknameSystem.Tick();
            m_MailSystem.Tick();
            //全局数据存储
            long saveStartTime = 0;
            var  dsThread      = UserServer.Instance.DataCacheThread;

            if (dsThread.DataStoreAvailable)
            {
                if (m_GuidCounter.IsTimeToSave(curTime))
                {
                    saveStartTime = TimeUtility.GetLocalMilliseconds();
                    dsThread.SaveGuid(m_GuidSystem.GuidList, m_GuidCounter.NextSaveCount);
                    LogSys.Log(LOG_TYPE.DEBUG, "GlobalDataSave Guid SaveCount:{0}, Time:{1}", m_GuidCounter.NextSaveCount, TimeUtility.GetLocalMilliseconds() - saveStartTime);
                    m_GuidCounter.IncreaseNextSaveCount();
                }
                if (m_MailCounter.IsTimeToSave(curTime))
                {
                    saveStartTime = TimeUtility.GetLocalMilliseconds();
                    dsThread.SaveMail(m_MailSystem.TotalMailList, m_MailCounter.NextSaveCount);
                    dsThread.SaveDeletedMail(m_MailSystem.TotalDeletedMailList, m_MailCounter.NextSaveCount);
                    m_MailSystem.ResetDeletedMailList();
                    LogSys.Log(LOG_TYPE.DEBUG, "GlobalDataSave Mail SaveCount:{0}, Time:{1}", m_MailCounter.NextSaveCount, TimeUtility.GetLocalMilliseconds() - saveStartTime);
                    m_MailCounter.IncreaseNextSaveCount();
                }
                if (m_IsLastSave && IsLastSaveAllDone())
                {
                    if (m_LastSaveFinished == false)
                    {
                        //全局数据(Guid、邮件)存储完成
                        LogSys.Log(LOG_TYPE.MONITOR, "DoLastSaveGlobalData Step_2: GlobalData last save done");
                        m_IsLastSave       = false;
                        m_LastSaveFinished = true;
                    }
                }
            }
        }
Exemplo n.º 18
0
        public void Tick()
        {
            try {
                if (this.CurrentState != RoomState.Active && this.CurrentState != RoomState.Finish)
                {
                    return;
                }

                long curTime = TimeUtility.GetLocalMilliseconds();
                if (m_LastLogTime + 60000 < curTime)
                {
                    m_LastLogTime = curTime;

                    LogSys.Log(LOG_TYPE.INFO, "Room.Tick {0}", RoomId);
                }

                if (this.CurrentState == RoomState.Active)
                {
                    Scene scene = ActiveScene;
                    if (null != scene)
                    {
                        scene.Tick();
                        OnTick();
                    }
                    m_DisconnectedUsers.Clear();
                    m_RequestDeleteUsers.Clear();
                    foreach (User user in m_RoomUserMgr.RoomUsers)
                    {
                        if (user != null)
                        {
                            user.Tick();
                            if (user.IsTimeout())
                            {
                                if (user.UserControlState == (int)UserControlState.User)
                                {
                                    m_DisconnectedUsers.Add(user);
                                }
                                else if (user.UserControlState == (int)UserControlState.Remove)
                                {
                                    m_RequestDeleteUsers.Add(user);
                                }
                                else if (user.UserControlState == (int)UserControlState.UserDropped)
                                {
                                    if (user.LastNotifyUserDropTime + c_NotifyUserDropInterval < curTime)
                                    {
                                        Msg_RL_UserDrop uaqBuilder = new Msg_RL_UserDrop();
                                        uaqBuilder.RoomId      = m_RoomId;
                                        uaqBuilder.UserGuid    = user.Guid;
                                        uaqBuilder.IsBattleEnd = false;
                                        m_Connector.SendMsgToLobby(uaqBuilder);

                                        user.LastNotifyUserDropTime = curTime;
                                    }
                                    //临时处理,踢掉断线的玩家
                                    user.UserControlState = (int)UserControlState.Remove;
                                }
                            }
                        }
                    }
                    foreach (User user in m_DisconnectedUsers)
                    {
                        m_RoomUserMgr.DropUser(user);
                    }
                    foreach (User user in m_RequestDeleteUsers)
                    {
                        m_RoomUserMgr.RemoveUser(user);
                    }
                    //todo:观察者掉线处理
                    for (int i = 0; i < m_RoomUserMgr.RoomObservers.Length; ++i)
                    {
                        Observer observer = m_RoomUserMgr.RoomObservers[i];
                        if (!observer.IsIdle)
                        {
                            observer.Tick();
                        }
                    }
                    if (!IsFieldRoom)
                    {
                        int userCount = GetActiveRoomUserCount();
                        if (userCount <= 0 && CanFinish)
                        {
                            if (GetMinimizeElapsedDroppedTime() > c_FinishTimeForNoUsers)
                            {
                                //若房间内玩家数目为0,结束战斗,关闭房间
                                Finish((int)CampIdEnum.Unkown);
                            }
                        }
                    }
                    //每个Tick结束,将空间属性同步给Peer,用于Peer转发消息
                    foreach (User user in m_RoomUserMgr.RoomUsers)
                    {
                        if (null != user && null != user.Info && null != user.Info.GetMovementStateInfo())
                        {
                            GameFramework.RoomPeer peer = user.GetPeer();
                            if (null != peer)
                            {
                                MovementStateInfo info = user.Info.GetMovementStateInfo();
                                peer.Position = info.GetPosition3D();
                                peer.FaceDir  = info.GetFaceDir();
                            }
                        }
                    }
                }
                else if (m_FinishTime + c_DeactiveWaitTime < curTime)
                {
                    Deactive();
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
Exemplo n.º 19
0
 private void TickEntities()
 {
     m_DeletedEntities.Clear();
     for (LinkedListNode <EntityInfo> linkNode = m_EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next)
     {
         EntityInfo info = linkNode.Value;
         info.RetireAttackerInfos(10000);
         if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged)
         {
             AttrCalculator.Calc(info);
             info.LevelChanged = false;
             info.GetSkillStateInfo().BuffChanged = false;
         }
         if (info.IsBorning)
         {
             if (info.BornTime <= 0)
             {
                 SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.BornSkillId);
                 if (info.BornSkillId > 0 && null != skillInfo)
                 {
                     info.BornTime = TimeUtility.GetLocalMilliseconds();
                     GfxSkillSystem.Instance.StartSkill(info.GetId(), skillInfo.ConfigData, 0);
                 }
                 else
                 {
                     info.IsBorning = false;
                     info.BornTime  = 0;
                     info.SetAIEnable(true);
                     info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible);
                 }
             }
             else if (info.BornTime + info.BornTimeout < TimeUtility.GetLocalMilliseconds())
             {
                 info.IsBorning = false;
                 info.BornTime  = 0;
                 info.SetAIEnable(true);
                 info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible);
             }
         }
         if (info.IsDead() && !info.NeedDelete)
         {
             if (info.CanDead)
             {
                 if (info.DeadTime <= 0)
                 {
                     SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.DeadSkillId);
                     if (info.DeadSkillId > 0 && null != skillInfo)
                     {
                         info.DeadTime = TimeUtility.GetLocalMilliseconds();
                         GfxSkillSystem.Instance.StopAllSkill(info.GetId(), true, false, true);
                         GfxSkillSystem.Instance.StartSkill(info.GetId(), skillInfo.ConfigData, 0);
                         OnEntityKilled(info);
                         EntityDrop(info); // 掉落
                     }
                     else
                     {
                         info.DeadTime   = 0;
                         info.NeedDelete = true;
                         OnEntityKilled(info);
                         EntityDrop(info); // 掉落
                     }
                 }
                 else if (info.DeadTime + info.DeadTimeout < TimeUtility.GetLocalMilliseconds())
                 {
                     info.DeadTime   = 0;
                     info.NeedDelete = true;
                 }
             }
             else
             {
                 info.CanDead = true;
             }
         }
         else
         {
             //每个tick复位CanDead,技能里需要鞭尸时应使用触发器每帧标记目标不可死亡(keeplive)
             info.CanDead = true;
         }
         if (info.NeedDelete)
         {
             m_DeletedEntities.Add(info);
         }
     }
     if (m_DeletedEntities.Count > 0)
     {
         int enemyCt  = 0;
         int friendCt = 0;
         for (int i = 0; i < m_DeletedEntities.Count; ++i)
         {
             EntityInfo ni = m_DeletedEntities[i];
             if (CharacterRelation.RELATION_ENEMY == EntityInfo.GetRelation(CampId, ni.GetCampId()))
             {
                 ++enemyCt;
             }
             else if (CharacterRelation.RELATION_FRIEND == EntityInfo.GetRelation(CampId, ni.GetCampId()))
             {
                 ++friendCt;
             }
             DestroyEntity(ni);
         }
         TryAllKilledOrAllDied(enemyCt > 0, friendCt > 0);
     }
 }
Exemplo n.º 20
0
        private void TickEntities()
        {
            m_DeletedEntities.Clear();
            for (LinkedListNode <EntityInfo> linkNode = m_EntityMgr.Entities.FirstNode; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                info.RetireAttackerInfos(60000);
                if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged)
                {
                    AttrCalculator.Calc(info);
                    info.LevelChanged = false;
                    info.GetSkillStateInfo().BuffChanged = false;
                }
                if (info.IsBorning)
                {
                    if (info.BornTime <= 0)
                    {
                        SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.BornSkillId);
                        if (info.BornSkillId > 0 && null != skillInfo)
                        {
                            info.BornTime = TimeUtility.GetLocalMilliseconds();
                        }
                        else
                        {
                            info.IsBorning = false;
                            info.BornTime  = 0;
                            info.SetAIEnable(true);
                            info.RemoveState(CharacterPropertyEnum.x3009_无敌);
                        }
                    }
                    else if (info.BornTime + info.BornTimeout < TimeUtility.GetLocalMilliseconds())
                    {
                        info.IsBorning = false;
                        info.BornTime  = 0;
                        info.SetAIEnable(true);
                        info.RemoveState(CharacterPropertyEnum.x3009_无敌);
                    }
                }
                if (info.IsDead() && !info.NeedDelete)
                {
                    if (info.DeadTime <= 0)
                    {
                        CalcKillIncome(info);
                        //发送npc死亡消息
                        Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead();
                        npcDeadBuilder.npc_id = info.GetId();
                        NotifyAllUser(RoomMessageDefine.Msg_RC_NpcDead, npcDeadBuilder);

                        SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.DeadSkillId);
                        if (info.DeadSkillId > 0 && null != skillInfo)
                        {
                            info.DeadTime = TimeUtility.GetLocalMilliseconds();
                            OnEntityKilled(info);
                        }
                        else
                        {
                            if (null == info.CustomData as User)
                            {
                                info.DeadTime   = 0;
                                info.NeedDelete = true;
                                OnEntityKilled(info);
                            }
                            else
                            {
                                info.DeadTime = TimeUtility.GetLocalMilliseconds();
                            }
                        }
                    }
                    else
                    {
                        if (null == info.CustomData as User && info.DeadTime + info.DeadTimeout < TimeUtility.GetLocalMilliseconds())
                        {
                            info.DeadTime   = 0;
                            info.NeedDelete = true;

                            //重新发送npc死亡消息
                            Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead();
                            npcDeadBuilder.npc_id = info.GetId();
                            NotifyAllUser(RoomMessageDefine.Msg_RC_NpcDead, npcDeadBuilder);
                        }
                        else if (null != info.CustomData as User && info.DeadTime + info.ReliveTimeout < TimeUtility.GetLocalMilliseconds())
                        {
                            info.DeadTime = 0;
                            info.Hp       = info.HpMax;
                            info.Energy   = info.EnergyMax;

                            Msg_RC_SyncProperty npcProp = DataSyncUtility.BuildSyncPropertyMessage(info);
                            NotifyAllUser(RoomMessageDefine.Msg_RC_SyncProperty, npcProp);
                        }
                    }
                }
                if (info.NeedDelete)
                {
                    m_DeletedEntities.Add(info);
                }
            }
            if (m_DeletedEntities.Count > 0)
            {
                int enemyCt  = 0;
                int friendCt = 0;
                Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc();
                for (int i = 0; i < m_DeletedEntities.Count; ++i)
                {
                    EntityInfo ni = m_DeletedEntities[i];
                    if (CharacterRelation.RELATION_ENEMY == EntityInfo.GetRelation((int)CampIdEnum.Blue, ni.GetCampId()))
                    {
                        ++enemyCt;
                    }
                    else if (CharacterRelation.RELATION_FRIEND == EntityInfo.GetRelation((int)CampIdEnum.Blue, ni.GetCampId()))
                    {
                        ++friendCt;
                    }
                    //发送npc消失消息
                    destroyNpcBuilder.npc_id = ni.GetId();
                    NotifyAllUser(RoomMessageDefine.Msg_RC_DestroyNpc, destroyNpcBuilder);
                    DestroyEntity(ni);
                }
                TryAllKilledOrAllDied(enemyCt > 0, friendCt > 0);
            }
            m_EntityMgr.ExecuteDelayAdd();
        }
Exemplo n.º 21
0
        protected override void OnTick()
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

            if (m_LastTickTime != 0)
            {
                long elapsedTickTime = curTime - m_LastTickTime;
                if (elapsedTickTime > c_WarningTickTime)
                {
                    LogSys.Log(LOG_TYPE.MONITOR, "QueueingThread Tick:{0}", elapsedTickTime);
                }
            }
            m_LastTickTime = curTime;

            if (m_LastLogTime + 60000 < curTime)
            {
                m_LastLogTime = curTime;
                DebugPoolCount((string msg) => {
                    LogSys.Log(LOG_TYPE.INFO, "QueueingThread.ActionQueue {0}", msg);
                });
                LogSys.Log(LOG_TYPE.MONITOR, "QueueingThread.ActionQueue Current Action {0}", this.CurActionNum);
            }

            const int c_MaxIterationPerTick = 10;

            if (IsLobbyFull() || GetTotalQueueingCount() <= 0)
            {
                //大厅已经满或者没有排队的玩家,多休息1秒
                System.Threading.Thread.Sleep(1000);
            }
            else
            {
                UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
                for (int i = 0; i < c_MaxIterationPerTick; ++i)
                {
                    if (m_QueueingAccounts.Count > 0 && null != m_QueueingAccounts.First && CanEnter())
                    {
                        string accountId = m_QueueingAccounts.First.Value;
                        m_QueueingAccounts.RemoveFirst();
                        m_LogoutQueueingAccounts.Remove(accountId);
                        IncEnterCount();
                        LoginInfo info;
                        if (m_QueueingInfos.TryRemove(accountId, out info))
                        {
                            dataProcess.DefaultUserThread.QueueAction(dataProcess.DoAccountLoginWithoutQueueing, accountId, info.Password, info.ClientInfo, info.NodeName);
                            ++i;
                        }
                    }
                }

                if (m_LastCleanTickTime + c_CleanTickInterval < curTime)
                {
                    m_LastCleanTickTime = curTime;

                    if (m_QueueingAccounts.Count > 0)
                    {
                        int ct          = 0;
                        int removeCount = 0;
                        for (LinkedListNode <string> node = m_QueueingAccounts.First; null != node && m_QueueingAccounts.Count > 0;)
                        {
                            ++ct;
                            if (ct > m_MaxQueueingCount)
                            {
                                LogSys.Log(LOG_TYPE.WARN, "QueueingThread.Tick maybe deadlock {0}", m_QueueingAccounts.Count);
                                break;
                            }
                            string    accountId = node.Value;
                            LoginInfo info;
                            if (m_LogoutQueueingAccounts.Contains(accountId))
                            {
                                m_LogoutQueueingAccounts.Remove(accountId);
                                m_QueueingInfos.TryRemove(accountId, out info);

                                ++removeCount;
                                LinkedListNode <string> delNode = node;
                                node = node.Next;
                                m_QueueingAccounts.Remove(delNode);
                            }
                            else if (m_QueueingInfos.TryGetValue(accountId, out info))
                            {
                                info.QueueingNum -= removeCount;
                                node              = node.Next;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 22
0
 private void Start_()
 {
     m_LastSnapshotTime = TimeUtility.GetElapsedTimeUs();
     m_StartTime        = m_LastSnapshotTime;
 }
Exemplo n.º 23
0
 public void SetAttackTime()
 {
     LastAttackTime = TimeUtility.GetLocalMilliseconds();
 }
Exemplo n.º 24
0
        private void Loop()
        {
            try {
                while (CenterHubApi.IsRun())
                {
                    long curTime = TimeUtility.GetLocalMilliseconds();
                    if (m_LastTickTime != 0)
                    {
                        long elapsedTickTime = curTime - m_LastTickTime;
                        if (elapsedTickTime > c_WarningTickTime)
                        {
                            LogSys.Log(LOG_TYPE.MONITOR, "GameFramework Network Tick:{0}", curTime - m_LastTickTime);
                        }
                    }
                    m_LastTickTime = curTime;

                    CenterHubApi.Tick();
                    Thread.Sleep(10);
                    if (m_WaitQuit)
                    {
                        if (m_GlobalProcessThread.LastSaveFinished && m_UserProcessScheduler.LastSaveFinished && m_QuitFinish == false)
                        {
                            //全局数据和玩家数据存储完毕
                            int saveReqCount = m_DataCacheThread.CalcSaveRequestCount();
                            LogSys.Log(LOG_TYPE.MONITOR, "QuitStep_1. GlobalData and UserData last save done. SaveRequestCount:{0}", saveReqCount);
                            if (saveReqCount > 0)
                            {
                                //等待5s
                                long startTime = TimeUtility.GetLocalMilliseconds();
                                while (startTime + 5000 > TimeUtility.GetLocalMilliseconds())
                                {
                                    CenterClientApi.Tick();
                                    Thread.Sleep(10);
                                }
                            }
                            else
                            {
                                //通知关闭DataCache
                                m_QuitFinish = true;
                                LogSys.Log(LOG_TYPE.MONITOR, "QuitStep_2. Notice DataCache to quit.");
                                CenterClientApi.SendCommandByName("DataCache", "QuitDataStore");
                                //等待10s
                                long startTime = TimeUtility.GetLocalMilliseconds();
                                while (startTime + 10000 > TimeUtility.GetLocalMilliseconds())
                                {
                                    CenterClientApi.Tick();
                                    Thread.Sleep(10);
                                }
                                //关闭GameFramework
                                LogSys.Log(LOG_TYPE.MONITOR, "QuitStep_3. LastSaveDone. GameFramework quit...");
                                CenterClientApi.Quit();
                            }
                        }
                        else
                        {
                            if (curTime - m_LastWaitQuitTime > c_WaitQuitTimeInterval)
                            {
                                m_WaitQuit = false;
                                LogSys.Log(LOG_TYPE.MONITOR, "QuitStep_-1. Reset m_WaitQuit to false.");
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "GameFramework.Loop throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
Exemplo n.º 25
0
        private void IOHandler()
        {
            while (m_Status == RoomSrvStatus.STATUS_RUNNING)
            {
                try {
                    m_NetServer.MessageReceivedEvent.WaitOne(1000);
                    long startTime = TimeUtility.GetElapsedTimeUs();
                    NetIncomingMessage im;
                    for (int ct = 0; ct < 1024; ++ct)
                    {
                        try {
                            if ((im = m_NetServer.ReadMessage()) != null)
                            {
                                switch (im.MessageType)
                                {
                                case NetIncomingMessageType.DebugMessage:
                                case NetIncomingMessageType.VerboseDebugMessage:
                                    LogSys.Log(LOG_TYPE.DEBUG, "Debug Message: {0}", im.ReadString());
                                    break;

                                case NetIncomingMessageType.ErrorMessage:
                                    LogSys.Log(LOG_TYPE.DEBUG, "Error Message: {0}", im.ReadString());
                                    break;

                                case NetIncomingMessageType.WarningMessage:
                                    LogSys.Log(LOG_TYPE.DEBUG, "Warning Message: {0}", im.ReadString());
                                    break;

                                case NetIncomingMessageType.StatusChanged:
                                    NetConnectionStatus status = (NetConnectionStatus)im.ReadByte();
                                    string reason = im.ReadString();
                                    if (null != im.SenderConnection)
                                    {
                                        RoomPeer peer = RoomPeerMgr.Instance.GetPeerByConnection(im.SenderConnection);
                                        if (null != peer)
                                        {
                                            LogSys.Log(LOG_TYPE.DEBUG, "Network Status Changed: {0} reason:{1} EndPoint:{2} Key:{3} User:{4}\nStatistic:{5}", status, reason, im.SenderEndPoint.ToString(), peer.GetKey(), peer.Guid, im.SenderConnection.Statistics.ToString());
                                        }
                                        else
                                        {
                                            LogSys.Log(LOG_TYPE.DEBUG, "Network Status Changed: {0} reason:{1} EndPoint:{2}\nStatistic:{3}", status, reason, im.SenderEndPoint.ToString(), im.SenderConnection.Statistics.ToString());
                                        }
                                    }
                                    else
                                    {
                                        LogSys.Log(LOG_TYPE.DEBUG, "Network Status Changed:{0} reason:{1}", status, reason);
                                    }
                                    break;

                                case NetIncomingMessageType.Data:
                                    int    id   = 0;
                                    object msg  = null;
                                    byte[] data = null;
                                    try {
                                        data = im.ReadBytes(im.LengthBytes);
                                        msg  = Serialize.Decode(data, out id);
                                    } catch {
                                        if (null != im.SenderConnection)
                                        {
                                            RoomPeer peer = RoomPeerMgr.Instance.GetPeerByConnection(im.SenderConnection);
                                            if (null != peer)
                                            {
                                                LogSys.Log(LOG_TYPE.WARN, "room server decode message error !!! from User:{0}({1})", peer.Guid, peer.GetKey());
                                            }
                                        }
                                    }
                                    if (msg != null)
                                    {
                                        m_Dispatch.Dispatch(id, msg, im.SenderConnection);
                                    }
                                    else
                                    {
                                        if (null != im.SenderConnection)
                                        {
                                            RoomPeer peer = RoomPeerMgr.Instance.GetPeerByConnection(im.SenderConnection);
                                            if (null != peer)
                                            {
                                                LogSys.Log(LOG_TYPE.DEBUG, "got unknow message !!! from User:{0}({1})", peer.Guid, peer.GetKey());
                                            }
                                            else
                                            {
                                                LogSys.Log(LOG_TYPE.DEBUG, "got unknow message !!!");
                                            }
                                        }
                                        else
                                        {
                                            LogSys.Log(LOG_TYPE.DEBUG, "got unknow message !!!");
                                        }
                                    }
                                    break;

                                default:
                                    break;
                                }
                                m_NetServer.Recycle(im);
                            }
                            else
                            {
                                break;
                            }
                        } catch (Exception ex) {
                            LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
                        }
                    }
                    RoomPeerMgr.Instance.Tick();
                    long endTime = TimeUtility.GetElapsedTimeUs();
                    if (endTime - startTime >= 10000)
                    {
                        LogSys.Log(LOG_TYPE.DEBUG, "Warning, IOHandler() cost {0} us !\nNetPeer Statistic:{1}", endTime - startTime, m_NetServer.Statistics.ToString());
                    }
                } catch (Exception ex) {
                    LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
                }

                Thread.Sleep(10);
            }
        }