public void CheckStatus(TransportClient client, long lastWrite, long lastRead, long lastConnect) { if (client.IsClose) { return; } long now = DateTime.Now.ToTime(); if (now - _lastCheck < _pingInterval) { return; } _lastCheck = now; if (!client.IsConnected()) { return; } if (IsSessionTimeout(now, lastRead, lastConnect)) { SessionTimeout(client); return; } if (IsWriteIdleTimeout(now, lastWrite) || IsReadIdleTimeout(now, lastRead)) { Ping(client); } }
protected abstract void Ping(TransportClient client);
protected virtual void SessionTimeout(TransportClient client) { client.CloseChannel(); }