/// <summary> /// Override this method to handle an A-ASSOCIATE-RJ. /// </summary> /// <param name="associateRj">The received A-ASSOCIATE-RJ.</param> /// <returns>Return true when this methods has handled the received A-ASSOCIATE-RJ, otherwise false.</returns> public virtual bool HandleAssociateReject(AssociateRj associateRj) { return false; }
/// <summary> /// This method is called after an A-ASSOCIATE-RJ has been received but before it /// (possibly) will be handled by the (zero or more) MessageHandler objects that /// are attached to this object. /// /// Default, nothing is done in this method. Override if needed. /// </summary> /// <param name="associateRj">The received A-ASSOCIATE-RJ</param> public virtual void BeforeHandlingAssociateReject(AssociateRj associateRj) { // Do nothing. }
/// <summary> /// Receive a message (can be a Dicom or Dul message). /// /// An exception is thrown when receiving of a message fails. /// </summary> /// <returns>The received message.</returns> public Message ReceiveMessage() { // Start Interface logging. // InterfaceLogging.Start(this); DicomProtocolMessage receivedMessage = null; DvtkData.Message dvtkDataMessage = null; WriteInformation("Receive message..."); Dvtk.Sessions.ReceiveReturnCode receiveReturnCode = DvtkScriptSession.Receive(out dvtkDataMessage); if (receiveReturnCode != Dvtk.Sessions.ReceiveReturnCode.Success) { DvtkHighLevelInterfaceException.Throw("Error while trying to receive a Message. Error code " + receiveReturnCode.ToString() + "."); } else { if (dvtkDataMessage is DvtkData.Dimse.DicomMessage) { receivedMessage = new DicomMessage(dvtkDataMessage as DvtkData.Dimse.DicomMessage); } else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_RQ) { lastAssociateRq = new AssociateRq(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_RQ); receivedMessage = lastAssociateRq; } else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_AC) { receivedMessage = new AssociateAc(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_AC); } else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_RJ) { receivedMessage = new AssociateRj(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_RJ); } else if (dvtkDataMessage is DvtkData.Dul.A_RELEASE_RQ) { receivedMessage = new ReleaseRq(dvtkDataMessage as DvtkData.Dul.A_RELEASE_RQ); } else if (dvtkDataMessage is DvtkData.Dul.A_RELEASE_RP) { receivedMessage = new ReleaseRp(dvtkDataMessage as DvtkData.Dul.A_RELEASE_RP); } else if (dvtkDataMessage is DvtkData.Dul.A_ABORT) { receivedMessage = new Abort(dvtkDataMessage as DvtkData.Dul.A_ABORT); } else { Debug.Assert(true, "Unexpected DvtkData Message descendant type."); } // If the options AutoValidate is true, try to validate as much // as possible for the received message. if (Options.AutoValidate) { Validate(receivedMessage); } receivedMessage.IsReceived = true; ThreadManager.DataWarehouse.AddMessage(this, receivedMessage); if (receivedMessage is ReleaseRq) { if (AssociationReleasedEvent != null) { AssociationReleasedEvent(this); } } } // End Interface logging. // InterfaceLogging.End(receivedMessage); return(receivedMessage); }
/// <summary> /// This method is called after an A-ASSOCIATE-RJ has been received and has /// (possibly) been handled by the (zero or more) MessageHandler objects that /// are attached to this object. /// /// Default, nothing is done in this method. Override if needed. /// </summary> /// <param name="associateRj">The received A-ASSOCIATE-RJ.</param> public virtual void AfterHandlingAssociateReject(AssociateRj associateRj) { // Do nothing. }