The VerificationSCPExtended example demonstrates how to use the DCF to implement a simple Verification (Echo) service class provider,
utilizing a callback to handle the CEchoRequest DIMSE messages.
Classes
Class | Description | |
---|---|---|
Program |
Basic verification service class provider example which should be run with the VerificationSCU.
| |
ProgramCallbackVerificationServer |
CallbackVerificationServer handles associations by creating a custom Verification SCP that extends
VerificationSCP to handle the C-ECHO requests on the association.
|
Remarks
Supported OS Platforms:
- Windows - .Net Framework 4.7.2 64-bit and 32-bit
- Windows - .Net Core 2.1 64-bit and 32-bit
- Linux - .Net Core 2.1 64-bit
Examples
VerificationSCPCallback Sample Code
public class Program { /// <summary> /// Main entry point for VerificationSCPCallback. /// </summary> [STAThread] public static void Main() { Console.Title = "LaurelBridge.DCFExamples.VerificationSCPCallback"; try { // only accept ELE or ILE for this server IList<AllowedPresentationContext> allowed = new List<AllowedPresentationContext>(); allowed.Add(new AllowedPresentationContext(Uids.VerificationSOPClass, Uids.TransferSyntax.ExplicitVRLittleEndian, Uids.TransferSyntax.ImplicitVRLittleEndian)); // Create a CallbackVerificationServer that listens for associations on port 10104 CallbackVerificationServer server10104 = new CallbackVerificationServer(10104, allowed); server10104.BeginListening(); Console.WriteLine("listening on {0}...", 10104); } catch (Exception e) { Console.WriteLine("Error during execution: {0}", e); Environment.ExitCode = 1; } } /// <summary> /// CallbackVerificationServer handles associations by creating a custom Verification SCP that extends /// VerificationSCP to handle the C-ECHO requests on the association. /// </summary> public class CallbackVerificationServer : AssociationListenerAdapter, IAssociationConfigPolicyManager { readonly AssociationManager _manager; readonly IList<AllowedPresentationContext> _presentationContexts; /// <summary> /// Callback verification server constructor. /// </summary> /// <param name="port">server port</param> public CallbackVerificationServer(int port) : this(port, null) { } /// <summary> /// Callback verification server with allowed presentation contexts. /// </summary> /// <param name="port">server port</param> /// <param name="allowedPresentationContexts">allowed presentation context list</param> public CallbackVerificationServer(int port, IList<AllowedPresentationContext> allowedPresentationContexts) { _presentationContexts = allowedPresentationContexts; _manager = new AssociationManager(); _manager.ServerTcpPort = port; _manager.AssociationConfigPolicyMgr = this; _manager.AddAssociationListener(this); } /// <summary> /// Start listening for associations via the AssociationManager. /// </summary> public void BeginListening() { Thread t = new Thread(_manager.Run); t.Start(); if (!_manager.WaitForRunning(2000)) { throw new TimeoutException("AssociationManager did not start in an acceptable amount of time"); } } /// <summary> /// Stop the server. /// </summary> public void Stop() { _manager.Stop(); } #region IAssociationConfigPolicyManager implementation /// <summary> /// Return the session settings for the given association acceptor. /// </summary> /// <param name="assoc">The AssociationException</param> /// <returns>the session settings</returns> public DicomSessionSettings GetSessionSettings(AssociationAcceptor assoc) { return new DicomSessionSettings(); } #endregion #region AssociationListenerAdapter overrides /// <summary> /// Call back for begin association. /// </summary> /// <param name="assoc">the AssociationAcceptor</param> public override void BeginAssociation(AssociationAcceptor assoc) { assoc.RegisterServiceClassProvider(new VerificationSCP(assoc, _presentationContexts, CEcho)); } #endregion /// <summary> /// Handler for CEcho. /// </summary> /// <param name="acceptor">The AssociationAcceptor</param> /// <param name="request">The C-Echo request message</param> /// <returns>The C-Echo response</returns> public CEchoResponse CEcho(AssociationAcceptor acceptor, CEchoRequest request) { CEchoResponse response = new CEchoResponse(request); Console.WriteLine("CallbackVerificationServer: cEcho request from {0} to port {1}", acceptor.AssociationInfo.CallingTitle, acceptor.AssociationInfo.CalledPresentationAddress); return response; } } }