Esempio n. 1
0
 async void AuthKeepAlive(CancellationToken token)
 {
     await Task.Run(async() =>
     {
         await Task.Delay(5000);
         while (true)
         {
             try
             {
                 long timeStamp  = CCTime.GetTimeStamp();
                 string str      = $"type@=keeplive/vbw@=0/cdn@=cmcc/tick@={timeStamp}/kd@={(kd == null ? "" : await Getkd(kd, ROOM_ID, devid, timeStamp))}/";
                 byte[] aliveMsg = DataToBytes(str);
                 if (token.IsCancellationRequested)
                 {
                     return;
                 }
                 AppLog.Info($"认证服务器【房间{ROOM_ID}】【发送心跳包】");
                 AuthClient.Send(aliveMsg);
                 await Task.Delay(20000);
             }
             catch (Exception ex)
             {
                 //if (AuthClient == null || AuthClient.ReadyState != WebSocketState.Open)
                 //    return;
                 AppLog.Error("【认证服务器】心跳异常", ex);
                 //if (!token.IsCancellationRequested)
                 //    Reconnect();
                 return;
             }
         }
     });
 }
Esempio n. 2
0
        private void _onProcess(float tmSlice)
        {        //todo profile
            List <IProcess> _remove = new List <IProcess>();
            int             i       = 0;
            IProcess        p;

            // 统计消息处理时间,profiler分析
            double startTm = CCTime.getTickMillisec();

            for (i = 0; i < _processVec.Count; i++)
            {
                p = _processVec[i];
                if (p == null)
                {
                    GameTools.PrintError("processQueue onProcess null!");
                    continue;
                }

                if (p.pause)
                {
                    continue;
                }
                if (p.destroy)
                {
                    _remove.Add(p);
                    continue;
                }


                double beginTm = CCTime.getTickMillisec();

                p.updateProcess(tmSlice);

                double procTm = CCTime.getTickMillisec() - beginTm;
                ProfilerManager.inst.profilerMark(procTm, _debugFlag, p.processName);

                if (startTm - beginTm > _limittmMS)
                {
                    break;
                }
            }

            foreach (IProcess match in _remove)
            {
                for (i = _processVec.Count - 1; i >= 0; i--)
                {
                    p = _processVec[i];
                    if (match != p)
                    {
                        continue;
                    }
                    _processVec.RemoveAt(i);
                    break;
                }
            }
        }
Esempio n. 3
0
        private void _onProcess(float tmSlice)
        {
            List <IProcess> list = new List <IProcess>();
            double          num  = (double)CCTime.getTickMillisec();

            for (int i = 0; i < this._processVec.Count; i++)
            {
                IProcess process = this._processVec[i];
                bool     flag    = process == null;
                if (flag)
                {
                    GameTools.PrintError("processQueue onProcess null!");
                }
                else
                {
                    bool pause = process.pause;
                    if (!pause)
                    {
                        bool destroy = process.destroy;
                        if (destroy)
                        {
                            list.Add(process);
                        }
                        else
                        {
                            double num2 = (double)CCTime.getTickMillisec();
                            process.updateProcess(tmSlice);
                            double procTm = (double)CCTime.getTickMillisec() - num2;
                            ProfilerManager.inst.profilerMark(procTm, this._debugFlag, process.processName);
                            bool flag2 = num - num2 > (double)this._limittmMS;
                            if (flag2)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            foreach (IProcess current in list)
            {
                for (int i = this._processVec.Count - 1; i >= 0; i--)
                {
                    IProcess process = this._processVec[i];
                    bool     flag3   = current != process;
                    if (!flag3)
                    {
                        this._processVec.RemoveAt(i);
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
 private void _process_updata(float tmSlice)
 {
     while (this._taskList.Count > 0)
     {
         taskEvent taskEvent = this._taskList[0];
         this._taskList.RemoveAt(0);
         double num = (double)CCTime.getTickMillisec();
         taskEvent.listenerFun(taskEvent.evt);
         double procTm = (double)CCTime.getTickMillisec() - num;
         ProfilerManager.inst.profilerMark(procTm, "gameEventDelegate", taskEvent.evt.type.ToString());
         taskEvent.free(taskEvent);
     }
 }
        private void _process_updata(float tmSlice)
        {        //  todo time limit and profile
            while (_taskList.Count > 0)
            {
                taskEvent t = _taskList[0];
                _taskList.RemoveAt(0);

#if DEBUG
                // 统计消息处理时间,profiler分析
                double beginTm = CCTime.getTickMillisec();
#endif

                t.listenerFun(t.evt);

#if DEBUG
                double procTm = CCTime.getTickMillisec() - beginTm;

                ProfilerManager.inst.profilerMark(procTm, "gameEventDelegate", t.evt.type.ToString());
#endif

                taskEvent.free(t);
            }
        }
Esempio n. 6
0
 static public long getTimer()
 {
     return(CCTime.getCurTimestampMS());
 }