Example #1
0
        private void OnKeepaliveTick(KeepaliveTick e)
        {
            if (!IncomingKeepaliveEnabled && !OutgoingKeepaliveEnabled)
            {
                return;
            }

            List<LinkSession> snapshot;
            using (new ReadLock(rwlock))
            {
                snapshot = new List<LinkSession>(sessions.Count);
                var list = sessions.Values;
                for (int i = 0, count = list.Count; i < count; ++i)
                {
                    snapshot.Add(list[i]);
                }
            }
            for (int i = 0, count = snapshot.Count; i < count; ++i)
            {
                var tcpSession = (AbstractTcpSession)snapshot[i];
                if (tcpSession.Connected)
                {
                    int failureCount = tcpSession.Keepalive(
                        incomingKeepaliveEnabled, outgoingKeepaliveEnabled);

                    if (MaxKeepaliveFailureCount > 0 &&
                        failureCount > MaxKeepaliveFailureCount)
                    {
                        Log.Error("{0} {1} closed due to the keepalive failure",
                            Name, tcpSession.Handle);

                        tcpSession.Close();
                    }
                }
            }
        }
Example #2
0
 static KeepaliveTicker()
 {
     Event = new KeepaliveTick { _Channel = Channel };
 }
Example #3
0
        private void OnKeepaliveTick(KeepaliveTick e)
        {
            if (!IncomingKeepaliveEnabled && !OutgoingKeepaliveEnabled)
            {
                return;
            }

            var tcpSession = (AbstractTcpSession)Session;
            if (tcpSession == null || !tcpSession.Connected)
            {
                return;
            }

            int failureCount = tcpSession.Keepalive(
                incomingKeepaliveEnabled, outgoingKeepaliveEnabled);

            if (MaxKeepaliveFailureCount > 0 &&
                failureCount > MaxKeepaliveFailureCount)
            {
                Log.Error("{0} {1} closed due to the keepalive failure",
                    Name, tcpSession.Handle);

                tcpSession.Close();
            }
        }