示例#1
0
        private void HandleAlert(Record record)
        {
            var alert = AlertMessage.Read(record.Data);

            if (alert.Level == AlertLevel.Warning && alert.Description == AlertDescription.CloseNotify)
            {
                var versionConfig = Services.GetRequiredService <VersionConfig>();
                var closeAlert    = new AlertMessage(AlertLevel.Warning, AlertDescription.CloseNotify);
                var closeRecord   = new Record(RecordType.Alert, versionConfig.Version, closeAlert.GetBytes());

                var connection = Services.GetRequiredService <Connection>();
                connection.WriteRecord(closeRecord);

                throw new Exception("Closing connection");
            }
        }