/// <summary> /// If the last transaction hasn't yet a given response given, a response is /// generated, otherwise a REPORT request with the namespace 000 (equivalent /// to a response) is generated /// </summary> /// <param name="reason">one of <tt>MessageAbortEvent</tt> response codes except CONTINUATIONFLAG</param> /// <param name="reasonExtraInfo">corresponds to the comment as defined on RFC 4975 formal syntax. If null, it isn't sent any comment.</param> override public void Abort(ResponseCodes reason, string reasonExtraInfo) { // Sanity checks if (LastSendTransaction == null) { throw new InternalError("abort was called on an incoming message without an assigned Transaction!"); } if (!ResponseCode.IsAbortCode(reason)) { throw new IllegalUseException("The reason must be one of the response codes on MessageAbortedEvent excluding the continuation flag reason"); } // Check to see if we already responded to the transaction being // received/last transaction known if (!LastSendTransaction.HasResponse) { LastSendTransaction.TransactionManager.GenerateResponse(LastSendTransaction, reason, reasonExtraInfo); } else // let's generate the REPORT { FailureReport failureReport = new FailureReport(this, Session, LastSendTransaction, "000", reason, reasonExtraInfo); // send it Session.TransactionManager.AddPriorityTransaction(failureReport); } // mark this message as aborted _aborted = true; }
/// <summary> /// this is when a received transaction will give a 200 response code this /// function is called independently of the (Failure/Success)-Report field /// /// basicly this function is called whenever any request is error free and /// awaiting to be processed (although the misleading name of the function /// this function may not generate any kind of response /// </summary> /// <param name="transaction"></param> protected void R200ProcessRequest(Transaction transaction) { _logger.Debug(string.Format("called r200 with {0}, message-id[{1}], associated connection (localURI): {2}", transaction, transaction.MessageId, Connection.LocalURI)); if (transaction.TransactionType == TransactionType.SEND) { try { GenerateResponse(transaction, ResponseCodes.RC200, null); } catch (IllegalUseException e1) { _logger.Error(string.Format("Generating a success report for transaction: {0}", transaction)); } IncomingMessage message = (IncomingMessage)transaction.Message; if (message != null && message.IsComplete) { _logger.Debug(string.Format("transaction: tId {0} has an associated message message-id: {1} that is complete", transaction.TransactionId, transaction.MessageId)); // if we have a complete message with content // get the associated session Session session = GetAssociatedSession(transaction); // TODO sanity check: check to see if message already // exists // (?! // no use atm also think twice about // maintaining the receivedMessages on Session) try { IncomingMessage validated = (IncomingMessage)message.Validate(); long callCount = validated.Counter.Count; validated.ReportMechanism.TriggerSuccessReport(validated, transaction, validated.LastCallReportCount, callCount); validated.LastCallReportCount = callCount; session.TriggerReceiveMessage(validated); } catch (Exception e) { try { FailureReport fr = new FailureReport(message, session, transaction, "000", ResponseCodes.RC400, e.Message); AddPriorityTransaction(fr); } catch { } } } } if (transaction.TransactionType == TransactionType.REPORT) { StatusHeader transactionStatusHeader = transaction.StatusHeader; string statusCodeString = transactionStatusHeader.StatusCode.ToString(); _logger.Debug(string.Format("{0} is a report! Status code: {1}", transaction.ToString(), statusCodeString)); // at the moment just trigger the report, doesn't save it or send // it: // // if (transactionStatusHeader.getNamespace() == 0) // REMOVE FIXME TODO the implementation exception should // be handled like this?! try { transaction.Session.TriggerReceivedReport(transaction); } catch (ImplementationException e) { _logger.Error("Calling triggerReceivedReport", e); } } }