상속: EndpointBase
예제 #1
0
		public void ProcessMessageTest()
		{
			// setup the client configurations
			TcpSendEndpoint sendEndpoint = new TcpSendEndpoint();
			TcpSendOptions options = new TcpSendOptions();
			options.Endpoint = new IPEndPoint(IPAddress.Loopback, 6789);
			sendEndpoint.Initialize(null, options);

			// start a tcp listener
			TcpListener listener = new TcpListener(new IPEndPoint(IPAddress.Any, 6789));
			listener.Start();

			// start the enpoint for processing
			sendEndpoint.StartProcessing();

			// send messages
			byte[] data = { 0x41, 0x41, 0x41, 0x41 };
			sendEndpoint.ProcessMessage(null, data); // AAAA

			// assert listener for receive of messages
			var socket = listener.AcceptSocket();
			byte[] readData = new byte[8];
			Assert.AreEqual(8, socket.Receive(readData, 0, 8, SocketFlags.None));

			// close the client
			sendEndpoint.StopProcessing();

			// close the server
			listener.Stop();

			// assert data is valid

			byte[] expectedData = { TcpSendOptions.SOH, TcpSendOptions.STX, 0x41, 0x41, 0x41, 0x41, TcpSendOptions.ETX, TcpSendOptions.EOT };
			Assert.IsTrue(expectedData.SequenceEqual(readData));
		}
예제 #2
0
		private Application CreateHl7Application(ApplicationHost pipelineManager)
		{
			Application application = new Application();

			// Endpoints

			{
				var receiveEndoint = new TcpReceiveEndpoint();
				TcpReceieveOptions options = new TcpReceieveOptions { Endpoint = new IPEndPoint(IPAddress.Any, 5678) };
				options.SohDelimiters = new byte[0];
				options.EotDelimiters = new byte[0];
				receiveEndoint.Initialize(_applicationHost, options);
				Port port = new Port { Endpoint = receiveEndoint };
				port.Assembers.Add(new Hl7Disassembler());
				application.Ports.Add(port);
			}
			{
				var sendEndpoint = new TcpSendEndpoint();
				TcpSendOptions options = new TcpSendOptions() { Endpoint = new IPEndPoint(IPAddress.Loopback, 8756) };
				options.SohDelimiters = new byte[0];
				options.EotDelimiters = new byte[0];
				sendEndpoint.Initialize(_applicationHost, options);
				Port port = new Port { Endpoint = sendEndpoint };
				port.Assembers.Add(new Hl7Assembler());
				application.Ports.Add(port);
			}
			{
				var fileEndpoint = new FileWriterEndpoint("service-output.txt", true, Encoding.UTF8, false);
				fileEndpoint.Initialize(_applicationHost, null);
				Port port = new Port { Endpoint = fileEndpoint };
				application.Ports.Add(port);
			}

			// Channels

			Channel channel = new Channel();
			channel.Source = new Source();
			application.Channels.Add(channel);

			{
				// This destination will transform the message
				Destination destination = new Destination();
				destination.Filters.Add(new DelegateFilter((src, message) => true));
				destination.Transformers.Add(new DelegateTransformer(TransformerTest));
				destination.Transformers.Add(new JavaScriptTransformer()
				{
					Script = @"

if(msg['MSH']['MSH.8'] != null) delete msg['MSH']['MSH.8'];
msg['MSH']['MSH.2'] = 'TEST';

"
				});
				channel.Destinations.Add(destination);
			}

			return application;
		}
예제 #3
0
        public void ProcessMessageTest()
        {
            // setup the client configurations
            TcpSendEndpoint sendEndpoint = new TcpSendEndpoint();
            TcpSendOptions  options      = new TcpSendOptions();

            options.Endpoint = new IPEndPoint(IPAddress.Loopback, 6789);
            sendEndpoint.Initialize(null, options);

            // start a tcp listener
            TcpListener listener = new TcpListener(new IPEndPoint(IPAddress.Any, 6789));

            listener.Start();

            // start the enpoint for processing
            sendEndpoint.StartProcessing();

            // send messages
            byte[] data = { 0x41, 0x41, 0x41, 0x41 };
            sendEndpoint.ProcessMessage(null, data);             // AAAA

            // assert listener for receive of messages
            var socket = listener.AcceptSocket();

            byte[] readData = new byte[8];
            Assert.AreEqual(8, socket.Receive(readData, 0, 8, SocketFlags.None));

            // close the client
            sendEndpoint.StopProcessing();

            // close the server
            listener.Stop();

            // assert data is valid

            byte[] expectedData = { TcpSendOptions.SOH, TcpSendOptions.STX, 0x41, 0x41, 0x41, 0x41, TcpSendOptions.ETX, TcpSendOptions.EOT };
            Assert.IsTrue(expectedData.SequenceEqual(readData));
        }