Ejemplo n.º 1
0
        private void StartConnectionMonitor(IPersistentConnection connection)
        {
            var sleepTimeout = connection.KeepAliveInteralSeconds * 1000;

            connection.Connect();

            this.Log(connection, $"Connection established");

            while (true)
            {
                Thread.Sleep(sleepTimeout);

                if (!connection.IsConnected)
                {
                    throw new Exception("Connection lost");
                }

                connection.KeepAlive();
                this.Debug(connection, "Keep alive sent successfully");
            }
        }