private async Task ProcessSendFatalAlert(Alert alert, CancellationToken token) { this.logger?.Warn("Processing fatal alert..."); try { // Create and encrypt the alert record Record record = new Record(RecordType.Alert, this._handshakeSession.NegotiatedVersion, alert.GetBytes()); this._recordHandler.ProcessOutputRecord(record); // Attempt sending the alert record await this._recordStream.SendAsync(new Record[] { record }, token); } catch (Exception ex) { this.logger?.Error("Processing fatal alert failed: {0}", ex.Message); } finally { if (this._recordStream != null) { this.logger?.Info("Closing record stream..."); this._recordStream.Flush(); this._recordStream.Close(); } } }
private void ProcessAlertRecord(Record record) { // TODO: Received an alert, handle correctly Alert alert = new Alert(record.Fragment); this.logger?.Debug("Received an alert: " + alert.Description); if (alert.Level == AlertLevel.Fatal) { // Fatal alerts don't need close notify _recordStream.Close(); throw new Exception("Received a fatal alert"); } }