Beispiel #1
0
        public static void Check(this SessionIdleCheckerComponent self)
        {
            Session session = self.GetParent <Session>();
            long    timeNow = TimeHelper.ClientNow();

#if !SERVER
            if (timeNow - session.LastRecvTime > 6 * 1000)
            {
                if (session.GetComponent <SwitchRouterComponent>() == null)
                {
                    session.AddComponent <SwitchRouterComponent>();
                }
            }
            return;
#else
            if (timeNow - session.LastRecvTime < 30 * 1000 && timeNow - session.LastSendTime < 30 * 1000)
            {
                return;
            }

            Log.Info(
                $"session timeout: {session.Id} {timeNow} {session.LastRecvTime} {session.LastSendTime} {timeNow - session.LastRecvTime} {timeNow - session.LastSendTime}");
            session.Error = ErrorCore.ERR_SessionSendOrRecvTimeout;

            session.Dispose();
#endif
        }
        public static void Check(this SessionIdleCheckerComponent self)
        {
            Session session = self.GetParent <Session>();
            long    timeNow = TimeHelper.ClientNow();

            if (timeNow - session.LastRecvTime < 30 * 1000 && timeNow - session.LastSendTime < 30 * 1000)
            {
                return;
            }

            Log.Info($"session timeout: {session.Id} {timeNow} {session.LastRecvTime} {session.LastSendTime} {timeNow - session.LastRecvTime} {timeNow - session.LastSendTime}");
            session.Error = ErrorCode.ERR_SessionSendOrRecvTimeout;

            session.Dispose();
        }