private Option <IState> HandleAlert(Record record) { // TODO any alerts we can handle? // TODO report alert to external handler? var alert = AlertMessage.Read(record.Data); return(UnexpectedMessage(alert)); }
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"); } }
private Option <IState> HandleHandshake(Record record) { var handshake = _reader.Read(record); if (handshake.Type == RecordType.Alert) { var alert = AlertMessage.Read(record.Data); return(UnexpectedMessage(alert)); } if (handshake.HandshakeType != HandshakeType.ClientKeyExchange) { return(UnexpectedMessage()); } return(Option.Some <IState>(HandleClientKeyExchangeState.New(ServiceProvider, (ClientKeyExchangeMessage)handshake))); }