<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5196103582241137578</id><updated>2012-01-29T16:20:15.360+01:00</updated><category term='Windows Phone 7'/><category term='Mono'/><category term='Communication'/><category term='Security'/><category term='Silverlight'/><category term='.NET'/><title type='text'>eneter.net</title><subtitle type='html'>Lightweight framework for interprocess communication</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>25</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-3066579897504181870</id><published>2012-01-29T16:20:00.000+01:00</published><updated>2012-01-29T16:20:15.369+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>SImple Request-Response Communication using TCP</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; Very simple example showing how to implement request-response communication using TCP.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Introduction&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The example bellow implements a request-response communication scenario using TCP. The client application sends a simple text message to the service. When the service receives the text message, it responses back to the client with the text message too.&lt;br /&gt;The whole implementation is very simple and requires&amp;nbsp; only few lines of code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The example can be downloaded from&amp;nbsp; &lt;a href="http://eneter.net/Downloads/Examples/SimpleTcp.zip"&gt;http://eneter.net/Downloads/Examples/SimpleTcp.zip&lt;/a&gt;.&lt;br /&gt;To run the example, first execute the service application and then the client application. You can run multiple client applications.&lt;br /&gt;&lt;br /&gt;The example bellow uses Eneter Messaging Framework that provides functionality for various communication scenarios.&lt;br /&gt;(The framework is free for non-commercial use (&lt;a href="http://eneter.net/LicenseAgreement.htm"&gt;License&lt;/a&gt;) and can be downloaded from http://www.eneter.net.&lt;br /&gt;More detailed technical info can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-ZQmNsuw27h0/TyVi7du1BeI/AAAAAAAABR8/WhJoCw06Vpk/s1600/SimpleTCPRequestResponseCommunication.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="160" src="http://4.bp.blogspot.com/-ZQmNsuw27h0/TyVi7du1BeI/AAAAAAAABR8/WhJoCw06Vpk/s640/SimpleTCPRequestResponseCommunication.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Client Application&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The client is a simple application containg a button to send a text message. When it receives the response message, it displayes it in the text box.&lt;br /&gt;&lt;br /&gt;The implementation is very simple.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace HelloWorldTcpClient&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;            OpenConnection();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OpenConnection()&lt;br /&gt;        {&lt;br /&gt;            // Create message sender.&lt;br /&gt;            // It sends string and as a response receives also string.&lt;br /&gt;            IDuplexTypedMessagesFactory aTypedMessagesFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            myMessageSender = aTypedMessagesFactory.CreateDuplexTypedMessageSender&amp;lt;string, string&amp;gt;();&lt;br /&gt;&lt;br /&gt;            // Subscribe to receive response messages.&lt;br /&gt;            myMessageSender.ResponseReceived += OnResponseReceived;&lt;br /&gt;&lt;br /&gt;            // Create TCP messaging.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexOutputChannel anOutputChannel = aMessaging.CreateDuplexOutputChannel("tcp://127.0.0.1:8055/");&lt;br /&gt;&lt;br /&gt;            // Attach the output channel to the message sender and be able&lt;br /&gt;            // send messages and receive responses.&lt;br /&gt;            myMessageSender.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Detach output channel and stop listening to response messages.&lt;br /&gt;            myMessageSender.DetachDuplexOutputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void SendMessageBtn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Send message.&lt;br /&gt;            myMessageSender.SendRequestMessage(MessageTextBox.Text);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OnResponseReceived(object sender, TypedResponseReceivedEventArgs&amp;lt;string&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // Display received response.&lt;br /&gt;            // Note: This response does not come in the UI thread.&lt;br /&gt;            //       Therefore, we ninvoke it in the UI thread.&lt;br /&gt;            InvokeInUIThread(() =&amp;gt; ReceivedResponseTextBox.Text = e.ResponseMessage);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Helper method to invoke some functionality in UI thread.&lt;br /&gt;        private void InvokeInUIThread(Action uiMethod)&lt;br /&gt;        {&lt;br /&gt;            // If we are not in the UI thread then we must synchronize via the invoke mechanism.&lt;br /&gt;            if (InvokeRequired)&lt;br /&gt;            {&lt;br /&gt;                Invoke(uiMethod);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                uiMethod();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private IDuplexTypedMessageSender&amp;lt;string, string&amp;gt; myMessageSender;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Service Application&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The service is a simple console application listening via TCP to messages. When it receives a message, it sends back the text message.&lt;br /&gt;&lt;br /&gt;Here is the whole service implementation:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace HelloWorldTcpService&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Create message receiver.&lt;br /&gt;            // It receives string and responses also string.&lt;br /&gt;            IDuplexTypedMessagesFactory aTypedMessagesFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            IDuplexTypedMessageReceiver&amp;lt;string, string&amp;gt; aMessageReceiver&lt;br /&gt;                = aTypedMessagesFactory.CreateDuplexTypedMessageReceiver&amp;lt;string, string&amp;gt;();&lt;br /&gt;&lt;br /&gt;            // Subscribe to receive messages.&lt;br /&gt;            aMessageReceiver.MessageReceived += OnMessageReceived;&lt;br /&gt;&lt;br /&gt;            // Create input channel that will listen messages via TCP.&lt;br /&gt;            IMessagingSystemFactory aTcpMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel anInputChannel = aTcpMessaging.CreateDuplexInputChannel("tcp://127.0.0.1:8055/");&lt;br /&gt;&lt;br /&gt;            // Attach the input channel to the message receiver and start listening.&lt;br /&gt;            aMessageReceiver.AttachDuplexInputChannel(anInputChannel);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("TCP service is running. To stop press ENTER.");&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&gt;            // Detach the input channel and stop listening.&lt;br /&gt;            aMessageReceiver.DetachDuplexInputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private static void OnMessageReceived(object sender, TypedRequestReceivedEventArgs&amp;lt;string&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // Display receive message.&lt;br /&gt;            Console.WriteLine("Received message: " + e.RequestMessage);&lt;br /&gt;&lt;br /&gt;            // Send back simple response.&lt;br /&gt;            string aResponseMessage = "Thanks for " + e.RequestMessage;&lt;br /&gt;            IDuplexTypedMessageReceiver&amp;lt;string, string&amp;gt; aReceiver&lt;br /&gt;                = (IDuplexTypedMessageReceiver&amp;lt;string, string&amp;gt;)sender;&lt;br /&gt;            aReceiver.SendResponseMessage(e.ResponseReceiverId, aResponseMessage);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And here are communicating applications.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-uA12ll4PHvw/TyVi8WQF2MI/AAAAAAAABSE/dmR96X-lh34/s1600/SimpleTCPRequestResponseUI.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="234" src="http://3.bp.blogspot.com/-uA12ll4PHvw/TyVi8WQF2MI/AAAAAAAABSE/dmR96X-lh34/s640/SimpleTCPRequestResponseUI.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-3066579897504181870?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/3066579897504181870/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2012/01/simple-request-response-communication.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/3066579897504181870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/3066579897504181870'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2012/01/simple-request-response-communication.html' title='SImple Request-Response Communication using TCP'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-ZQmNsuw27h0/TyVi7du1BeI/AAAAAAAABR8/WhJoCw06Vpk/s72-c/SimpleTCPRequestResponseCommunication.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-6275185184640707463</id><published>2012-01-22T21:12:00.001+01:00</published><updated>2012-01-22T21:13:58.360+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>How to Implement Load Balancing to Distribute Workload</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; Simple example showing how to implement the load balancing if you need to increase the performance by distributing the workload across multiple services.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Introduction&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The example demonstrates a communication scenario where the capacity of one running service is not enough and you want to increase the performance by distributing the workload across multiple services.&lt;br /&gt;To simulate the scenario, the example below implements a client application using a service to calculate π (PI) number. The calculation is split into many small intervals (400 in our example).&lt;br /&gt;Therefore, the service gets overloaded and the performance drops down.&lt;br /&gt;&lt;br /&gt;The solution for such scenarios could be using of load balancer. The load balancer is a component maintaining a farm of services (typically same services but running on different machines) and is exposed to receive messages instead of the real service. The client does not know about this setup and thinks it communicates directly with the service. When the client sends a request, the load balancer receives this message and forwards it to the service picked from the farm. The service processes the message and sends back the response that is routed via the load balancer back to the client.&lt;br /&gt;&lt;br /&gt;The example can be downloaded from &lt;a href="http://eneter.net/Downloads/Examples/LoadBalancing.zip"&gt;http://eneter.net/Downloads/Examples/LoadBalancing.zip&lt;/a&gt;. &lt;br /&gt;To run the example applications must be executed in the following order:&lt;br /&gt;1. PiCalculator&amp;nbsp; up to 3 instances.&lt;br /&gt;2. LoadBalancer&lt;br /&gt;3. Client&lt;br /&gt;&lt;br /&gt;The example bellow uses Eneter Messaging Framework that provides functionality for various communication scenarios.&lt;br /&gt;(The framework is free for non-commercial use (&lt;a href="http://eneter.net/LicenseAgreement.htm"&gt;License&lt;/a&gt;) and can be downloaded from &lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net&lt;/a&gt;.&lt;br /&gt;More detailed technical info can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-liNzmh6LSp8/Txxp5kVz96I/AAAAAAAABR0/RXxW9OiI51A/s1600/UsingOfLoadBalancer.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="202" src="http://1.bp.blogspot.com/-liNzmh6LSp8/Txxp5kVz96I/AAAAAAAABR0/RXxW9OiI51A/s640/UsingOfLoadBalancer.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Client&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The client is a simple application containing a button sending the request to the service to calculate π (PI) number. The calculation is split into many small intervals. Therefore, the client sends about 400 messages each containing a small interval for the calculation.&lt;br /&gt;Then it collects all responses and summarizes them together to get the final result, the PI number.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace Client&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        // Requested calculation range.&lt;br /&gt;        public class Range&lt;br /&gt;        {&lt;br /&gt;            public double From;&lt;br /&gt;            public double To;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;            OpenConnection();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void OpenConnection()&lt;br /&gt;        {&lt;br /&gt;            // Create TCP messaging for the communication.&lt;br /&gt;            // Note: Requests are sent to the balancer that will forward them&lt;br /&gt;            //       to available services.&lt;br /&gt;            IMessagingSystemFactory myMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexOutputChannel anOutputChannel = myMessaging.CreateDuplexOutputChannel("tcp://127.0.0.1:8060/");&lt;br /&gt;&lt;br /&gt;            // Create sender to send requests.&lt;br /&gt;            IDuplexTypedMessagesFactory aSenderFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            mySender = aSenderFactory.CreateDuplexTypedMessageSender&amp;lt;double, Range&amp;gt;();&lt;br /&gt;&lt;br /&gt;            // Subscribe to receive response messages.&lt;br /&gt;            mySender.ResponseReceived += OnResponseReceived;&lt;br /&gt;&lt;br /&gt;            // Attach the output channel and be able to send messages and receive responses.&lt;br /&gt;            mySender.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Detach the output channel and stop listening for responses.&lt;br /&gt;            mySender.DetachDuplexOutputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void CalculatePiBtn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myCalculatedPi = 0.0;&lt;br /&gt;&lt;br /&gt;            // Split calculation of PI to 400 ranges and sends them for the calculation.&lt;br /&gt;            for (double i = -1.0; i &amp;lt;= 1.0; i += 0.005)&lt;br /&gt;            {&lt;br /&gt;                Range anInterval = new Range() { From = i, To = i + 0.005 };&lt;br /&gt;                mySender.SendRequestMessage(anInterval);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OnResponseReceived(object sender, TypedResponseReceivedEventArgs&amp;lt;double&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // Receive responses (calculations for ranges) and calculate PI.&lt;br /&gt;            myCalculatedPi += e.ResponseMessage;&lt;br /&gt;&lt;br /&gt;            // Display the number.&lt;br /&gt;            // Note: The UI control can be used only from the UI thread.&lt;br /&gt;            InvokeInUIThread(() =&amp;gt; ResultTextBox.Text = myCalculatedPi.ToString());&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Helper method to invoke some functionality in UI thread.&lt;br /&gt;        private void InvokeInUIThread(Action uiMethod)&lt;br /&gt;        {&lt;br /&gt;            // If we are not in the UI thread then we must synchronize via the invoke mechanism.&lt;br /&gt;            if (InvokeRequired)&lt;br /&gt;            {&lt;br /&gt;                Invoke(uiMethod);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                uiMethod();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private IDuplexTypedMessageSender&amp;lt;double, Range&amp;gt; mySender;&lt;br /&gt;        private double myCalculatedPi;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Load Balancer&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The load balancer is a simple console application acting as a real service. In this example it has a farm of three services. (To keep things simple, all three services run on the same computer. They listens to different ports.)&lt;br /&gt;When a user presses the button in the client application, the load balancer receives about 400 request messages and distributes them to its three services from the farm.&lt;br /&gt;To decide which service is picked from the farm, the load balancer uses Round-Robin algorithm. Therefore, all services are chosen evenly.&lt;br /&gt;(The Round-Robin algorithm is suitable for load balancing if processing of requests takes approximately same time.)&lt;br /&gt;&lt;br /&gt;The code is very simple. The whole implementation is here:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.LoadBalancer;&lt;br /&gt;&lt;br /&gt;namespace LoadBalancer&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Create TCP messaging for the communication with the client&lt;br /&gt;            // and with services performing requests.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Create load balancer.&lt;br /&gt;            // It receives requests from the client and forwards them to available services&lt;br /&gt;            // to balance the workload.&lt;br /&gt;            ILoadBalancerFactory aLoadBalancerFactory = new RoundRobinBalancerFactory(aMessaging);&lt;br /&gt;            ILoadBalancer aLoadBalancer = aLoadBalancerFactory.CreateLoadBalancer();&lt;br /&gt;&lt;br /&gt;            // Addresses of available services.&lt;br /&gt;            string[] anAvailableServices = {&lt;br /&gt;                       "tcp://127.0.0.1:8071/", "tcp://127.0.0.1:8072/", "tcp://127.0.0.1:8073/" };&lt;br /&gt;&lt;br /&gt;            // Add IP addresses of services to the load balancer.&lt;br /&gt;            foreach (string anIpAddress in anAvailableServices)&lt;br /&gt;            {&lt;br /&gt;                aLoadBalancer.AddDuplexOutputChannel(anIpAddress);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            // Create input channel that will listen to requests from clients.&lt;br /&gt;            IDuplexInputChannel anInputChannel = aMessaging.CreateDuplexInputChannel("tcp://127.0.0.1:8060/");&lt;br /&gt;&lt;br /&gt;            // Attach the input channel to the load balancer and start listening.&lt;br /&gt;            aLoadBalancer.AttachDuplexInputChannel(anInputChannel);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("Load Balancer is running.\r\nPress ENTER to stop.");&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&gt;            // Stop lisening.&lt;br /&gt;            aLoadBalancer.DetachDuplexInputChannel();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;PI Calculator&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The calculator is a simple service (console application). It receives requests to perform calculations for specific intervals. When the calculation is done, it sends back the calculation result.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Net;&lt;br /&gt;using System.Net.NetworkInformation;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace PiCalculator&lt;br /&gt;{&lt;br /&gt;    // Requested calculation range.&lt;br /&gt;    public class Range&lt;br /&gt;    {&lt;br /&gt;        public double From;&lt;br /&gt;        public double To;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            string aServiceAddress = GetMyAddress();&lt;br /&gt;            if (aServiceAddress == "")&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine("The service could not start because all possible ports are occupied.");&lt;br /&gt;                return;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            // Create TCP messaging for receiving requests.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel anInputChannel = aMessaging.CreateDuplexInputChannel(aServiceAddress);&lt;br /&gt;&lt;br /&gt;            // Create typed message receiver to receive requests.&lt;br /&gt;            // It receives request messages of type Range and sends back&lt;br /&gt;            // response messages of type double.&lt;br /&gt;            IDuplexTypedMessagesFactory aReceiverFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            IDuplexTypedMessageReceiver&amp;lt;double, Range&amp;gt; aReceiver&lt;br /&gt;                = aReceiverFactory.CreateDuplexTypedMessageReceiver&amp;lt;double, Range&amp;gt;();&lt;br /&gt;&lt;br /&gt;            // Subscribre to messages.&lt;br /&gt;            aReceiver.MessageReceived += OnMessageReceived;&lt;br /&gt;&lt;br /&gt;            // Attach the input channel and start listening.&lt;br /&gt;            aReceiver.AttachDuplexInputChannel(anInputChannel);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("Root Square Calculator listening to " + aServiceAddress +&lt;br /&gt;                " is running.\r\n Press ENTER to stop.");&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&gt;            // Detach the input channel and stop listening.&lt;br /&gt;            aReceiver.DetachDuplexInputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private static void OnMessageReceived(object sender, TypedRequestReceivedEventArgs&amp;lt;Range&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            Console.WriteLine("Calculate From: {0} To: {1}", e.RequestMessage.From, e.RequestMessage.To);&lt;br /&gt;&lt;br /&gt;            // Calculate requested range.&lt;br /&gt;            double aResult = 0.0;&lt;br /&gt;            double aDx = 0.000000001;&lt;br /&gt;            for (double x = e.RequestMessage.From; x &amp;lt; e.RequestMessage.To; x += aDx)&lt;br /&gt;            {&lt;br /&gt;                aResult += 2 * Math.Sqrt(1 - x * x) * aDx;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            // Response back the result.&lt;br /&gt;            IDuplexTypedMessageReceiver&amp;lt;double, Range&amp;gt; aReceiver&lt;br /&gt;                = (IDuplexTypedMessageReceiver&amp;lt;double, Range&amp;gt;)sender;&lt;br /&gt;            aReceiver.SendResponseMessage(e.ResponseReceiverId, aResult);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Helper method to get the address.&lt;br /&gt;        // Note: Since our example services are running on the same machine,&lt;br /&gt;        //       we must ensure they do not try to listen to the same IP address.&lt;br /&gt;        private static string GetMyAddress()&lt;br /&gt;        {&lt;br /&gt;            List&amp;lt;int&amp;gt; aPossiblePorts = new List&amp;lt;int&amp;gt;(new int[]{ 8071, 8072, 8073 });&lt;br /&gt;&lt;br /&gt;            // When we execute this service three time we want to get three instances&lt;br /&gt;            // listening to different port.&lt;br /&gt;            IPGlobalProperties anIpGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();&lt;br /&gt;            IPEndPoint[] aTcpListeners = anIpGlobalProperties.GetActiveTcpListeners();&lt;br /&gt;&lt;br /&gt;            // Remove from the possible ports those which are used.&lt;br /&gt;            foreach (IPEndPoint aListener in aTcpListeners)&lt;br /&gt;            {&lt;br /&gt;                aPossiblePorts.Remove(aListener.Port);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            // Get the first available port.&lt;br /&gt;            if (aPossiblePorts.Count &amp;gt; 0)&lt;br /&gt;            {&lt;br /&gt;                return "tcp://127.0.0.1:" + aPossiblePorts[0] + "/";&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            // All three instances are used.&lt;br /&gt;            return "";&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And here are all applications communicating together.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-ngtMoJjPBLg/Txxl0-EpiII/AAAAAAAABRs/aA_30aPnXI8/s1600/LoadBalancingApplicationUI.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="418" src="http://4.bp.blogspot.com/-ngtMoJjPBLg/Txxl0-EpiII/AAAAAAAABRs/aA_30aPnXI8/s640/LoadBalancingApplicationUI.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-6275185184640707463?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/6275185184640707463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2012/01/how-to-implement-load-balancing-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/6275185184640707463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/6275185184640707463'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2012/01/how-to-implement-load-balancing-to.html' title='How to Implement Load Balancing to Distribute Workload'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-liNzmh6LSp8/Txxp5kVz96I/AAAAAAAABR0/RXxW9OiI51A/s72-c/UsingOfLoadBalancer.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-8024031609663007612</id><published>2011-10-23T21:38:00.004+02:00</published><updated>2011-10-27T22:08:18.205+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Silverlight: Notification Messages from Desktop Application</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; A simple example showing how a Silverlight application can subscribe for notification messages from a desktop application.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Introduction&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The example bellow shows a scenario where the Silverlight application needs to observe desired events from a desktop application.&lt;br /&gt;(E.g. some data got updated and your Silverlight client needs to react accordingly.)&lt;br /&gt;&lt;br /&gt;The example consists of the Silverlight application and the standalone desktop application.&lt;br /&gt;The desktop application calculates given numbers and notifies the result via the broker.&lt;br /&gt;The Silverlight client subscribes in the broker to be notified whenever a calculation is performed. &lt;br /&gt;Silverlight and desktop communicates via TCP.&lt;br /&gt;&lt;br /&gt;The example is based on the Eneter Messaging Framework that provides components for various communication scenarios.&lt;br /&gt;(The framework is free for non-commercial use (&lt;a href="http://www.eneter.net/LicenseAgreement.htm"&gt;License&lt;/a&gt;) and can be downloaded from &lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net&lt;/a&gt;.&lt;br /&gt;The online help for developers can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;.) &lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-4zHVgkN2X4E/TqRoMrNAaLI/AAAAAAAABQ0/BO-5SNB3VsQ/s1600/SilverlightReceivesNotificationsfromDesktop.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="250" src="http://4.bp.blogspot.com/-4zHVgkN2X4E/TqRoMrNAaLI/AAAAAAAABQ0/BO-5SNB3VsQ/s640/SilverlightReceivesNotificationsfromDesktop.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Desktop Application&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The desktop application is responsible for counting two numbers and notifying the result to subscribed clients.&lt;br /&gt;As you can see on the picture, the desktop application contains three communication components:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;TCP Policy Server&lt;/li&gt;&lt;li&gt;Broker&lt;/li&gt;&lt;li&gt;Duplex Dispatcher.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;TCP Policy Server&lt;/b&gt;&lt;br /&gt;The TCP communication between Silverlight and a desktop application requires the policy server. The policy server is the special service listening to the port 943. When a Silverlight application tries to open the TCP connection the Silverlight framework internally sends the request to the port 943 and waits for the response. The policy server receives the request and responses with the policy file.&lt;br /&gt;If the policy file allows the communication, Silverlight opens the connection and the communication can start.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Broker&lt;/b&gt;&lt;br /&gt;The Broker is the component providing the publish-subscribe communication. In our case, the Silverlight client uses BrokerClient to subscribe for desired notification messages.&lt;br /&gt;The desktop application uses BrokerClient to send notification messages to the broker.&lt;br /&gt;Then when Broker receives the notification message, it forwards it to all subscribed clients.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Duplex Dispatcher&lt;/b&gt;&lt;br /&gt;The Duplex Dispatcher allows Broker communicating via TCP and the local Synchronous messaging at the same time.&lt;br /&gt;The reason is, the Silverlight client communicates via TCP, but the internal BrokerClient communicates via Synchronous messaging (because it would not be effective to communicate inside one process via TCP).&lt;br /&gt;Therefore, the Dispatcher component is used. The Dispatcher component receives messages on attached input ports and forwards them to all attached output ports.&lt;br /&gt;In our case the Dispatcher receives messages via TCP and Synchronous Messaging and forwards them to the Broker.&lt;br /&gt;&lt;br /&gt;The implementation is here: &lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.SynchronousMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.Broker;&lt;br /&gt;using Eneter.Messaging.Nodes.Dispatcher;&lt;br /&gt;&lt;br /&gt;namespace DesktopCalculator&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        private TcpPolicyServer myPolicyServer;&lt;br /&gt;        private IDuplexBrokerClient myBrokerClient;&lt;br /&gt;        private IDuplexDispatcher myDispatcher;&lt;br /&gt;&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Start the policy server.&lt;br /&gt;            // Note: Silverlight requires the policy server to start the communication.&lt;br /&gt;            //       The policy server tells the silverlight if the communication is permitted.&lt;br /&gt;            myPolicyServer = new TcpPolicyServer();&lt;br /&gt;            myPolicyServer.StartPolicyServer();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            // Local messaging connecting the Dispatcher and the Broker.&lt;br /&gt;            IMessagingSystemFactory aLocalMessaging = new SynchronousMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Create the broker forwarding notifications to subscribed clients.&lt;br /&gt;            IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory();&lt;br /&gt;            IDuplexBroker aBroker = aBrokerFactory.CreateBroker();&lt;br /&gt;&lt;br /&gt;            // Attach the input channel to the broker.&lt;br /&gt;            // Note: The broker will receive via this channel messages from the Dispatcher.&lt;br /&gt;            IDuplexInputChannel aBrokerInputChannel =&lt;br /&gt;                aLocalMessaging.CreateDuplexInputChannel("MyBrokerChannelId");&lt;br /&gt;            aBroker.AttachDuplexInputChannel(aBrokerInputChannel);&lt;br /&gt;&lt;br /&gt;            // Create the dispatcher.&lt;br /&gt;            // The dispatcher will receive TCP messages and also local messages and forward them&lt;br /&gt;            // to the broker.&lt;br /&gt;            // (I.e. broker can get messages from local messaging and from TCP at the same time.)&lt;br /&gt;            IDuplexDispatcherFactory aDispatcherFactory = new DuplexDispatcherFactory(aLocalMessaging);&lt;br /&gt;            myDispatcher = aDispatcherFactory.CreateDuplexDispatcher();&lt;br /&gt;&lt;br /&gt;            // Add the broker channel to the dispatcher.&lt;br /&gt;            myDispatcher.AddDuplexOutputChannel("MyBrokerChannelId");&lt;br /&gt;&lt;br /&gt;            // Attach the input channel receiving messages from the broker client.&lt;br /&gt;            // Note: The channel id is same as the broker client has.&lt;br /&gt;            IDuplexInputChannel aDispatcherLocalInputChannel =&lt;br /&gt;                aLocalMessaging.CreateDuplexInputChannel("MyLocalBrokerClientId");&lt;br /&gt;            myDispatcher.AttachDuplexInputChannel(aDispatcherLocalInputChannel);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            // Create the broker client notifying calculated results to the broker.&lt;br /&gt;            myBrokerClient = aBrokerFactory.CreateBrokerClient();&lt;br /&gt;&lt;br /&gt;            // Attach the output channel to the broker.&lt;br /&gt;            // Note: The broker client will use this channel to send messages to the dispatcher.&lt;br /&gt;            IDuplexOutputChannel aBrokerClientOutputChannel =&lt;br /&gt;                aLocalMessaging.CreateDuplexOutputChannel("MyLocalBrokerClientId");&lt;br /&gt;            myBrokerClient.AttachDuplexOutputChannel(aBrokerClientOutputChannel);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            // TCP messaging for the communication with the Silverlight client.&lt;br /&gt;            IMessagingSystemFactory aTcpMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Note: Silverlight can communicate only on ports: 4502-4532&lt;br /&gt;            IDuplexInputChannel aTcpInputChannel =&lt;br /&gt;                aTcpMessaging.CreateDuplexInputChannel("tcp://127.0.0.1:4510");&lt;br /&gt;&lt;br /&gt;            // Finaly attach the TCP input channel to the dispatcher and start listening&lt;br /&gt;            // to Silverlight clients.&lt;br /&gt;            myDispatcher.AttachDuplexInputChannel(aTcpInputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Detach input channels from the dispatcher and stop the listening.&lt;br /&gt;            myDispatcher.DetachDuplexInputChannel();&lt;br /&gt;&lt;br /&gt;            // Stop the policy server.&lt;br /&gt;            myPolicyServer.StopPolicyServer();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void CalculateBtn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Calculate numbers.&lt;br /&gt;            int aResult = int.Parse(Number1TextBox.Text) + int.Parse(Number2TextBox.Text);&lt;br /&gt;&lt;br /&gt;            // Show the result in the text box.&lt;br /&gt;            ResultTextBox.Text = aResult.ToString();&lt;br /&gt;&lt;br /&gt;            // Notify the result to the broker.&lt;br /&gt;            myBrokerClient.SendMessage("MyResultMessageId", ResultTextBox.Text);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Silverlight Client Application&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The Silverlight client is responsible for subscribing to receive notifications from the desktop application - whenewer two numbers are calculated.&lt;br /&gt;To subscribe for messages, the Silverlight application uses BrokerClient communicating via the TCP channel with the desktop application.&lt;br /&gt;&lt;br /&gt;The implementation of the client is here: &lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System.Windows;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.Broker;&lt;br /&gt;&lt;br /&gt;namespace SilverlightObserver&lt;br /&gt;{&lt;br /&gt;    public partial class MainPage : UserControl&lt;br /&gt;    {&lt;br /&gt;        private IDuplexBrokerClient myBrokerClient;&lt;br /&gt;        private bool myIsSubscribedFlag;&lt;br /&gt;&lt;br /&gt;        public MainPage()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create the BrokerClient to subscribe and receive notifications.&lt;br /&gt;            IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory();&lt;br /&gt;            myBrokerClient = aBrokerFactory.CreateBrokerClient();&lt;br /&gt;&lt;br /&gt;            // Handle received notifications.&lt;br /&gt;            myBrokerClient.BrokerMessageReceived += OnBrokerMessageReceived;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            // TCP messaging for the communication with the desktop application.&lt;br /&gt;            IMessagingSystemFactory aTcpMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Create the TCP output channel and attach it to the BrokerClient.&lt;br /&gt;            IDuplexOutputChannel aTcpOutputChannel =&lt;br /&gt;                aTcpMessaging.CreateDuplexOutputChannel("tcp://127.0.0.1:4510");&lt;br /&gt;&lt;br /&gt;            myBrokerClient.AttachDuplexOutputChannel(aTcpOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        private void LayoutRoot_Unloaded(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Detach the TCP output channel and stop the communication.&lt;br /&gt;            myBrokerClient.DetachDuplexOutputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void SubscribeBtn_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // If not subscribed, then subscribe for the same type&lt;br /&gt;            // as is notified from the desktop.&lt;br /&gt;            if (!myIsSubscribedFlag)&lt;br /&gt;            {&lt;br /&gt;                myBrokerClient.Subscribe("MyResultMessageId");&lt;br /&gt;                myIsSubscribedFlag = true;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void UnsubscribeBtn_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // If subscribed, then unsubscribe.&lt;br /&gt;            if (myIsSubscribedFlag)&lt;br /&gt;            {&lt;br /&gt;                myBrokerClient.Unsubscribe();&lt;br /&gt;                myIsSubscribedFlag = false;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OnBrokerMessageReceived(object sender, BrokerMessageReceivedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Display the notified message.&lt;br /&gt;            ResultTextBox.Text = e.Message as string;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Communicating Applications&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-ozu9oeEqnU0/TqRrYjbSejI/AAAAAAAABQ8/__GOrKzuAAo/s1600/SilverlightNotificationFromDesktopUI.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-ozu9oeEqnU0/TqRrYjbSejI/AAAAAAAABQ8/__GOrKzuAAo/s1600/SilverlightNotificationFromDesktopUI.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Have a nice day :-)&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-8024031609663007612?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/8024031609663007612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2011/10/silverlight-notification-messages-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/8024031609663007612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/8024031609663007612'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2011/10/silverlight-notification-messages-from.html' title='Silverlight: Notification Messages from Desktop Application'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-4zHVgkN2X4E/TqRoMrNAaLI/AAAAAAAABQ0/BO-5SNB3VsQ/s72-c/SilverlightReceivesNotificationsfromDesktop.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-9088445697137988651</id><published>2011-10-21T00:23:00.007+02:00</published><updated>2011-10-27T22:08:43.584+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows Phone 7'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Mono'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Eneter Messaging Framework 3.0</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; The third version of the messaging framework for the interprocess communication.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;Eneter Messaging Framework is a lightweight framework for the interprocess communication based on messages.&lt;br /&gt;Although the framework is lightweight (the assembly has about 300Kb), it provides quite comprehensive functionality allowing to implement advanced communication scenarios too.&lt;br /&gt;(E.g. Service listening to HTTP and TCP at the same time, Communication across unstable network, Load Balancing, etc.)&lt;br /&gt;&lt;br /&gt;The framework is free for non-comercial use (&lt;a href="http://www.eneter.net/LicenseAgreement.htm"&gt;License&lt;/a&gt;) and runs in &lt;span style="color: black;"&gt;&lt;i&gt;.NET 3.5&lt;/i&gt;, &lt;i&gt;.NET 4.0&lt;/i&gt;, &lt;i&gt;Windows Phone 7&lt;/i&gt;, &lt;i&gt;Silverlight 3&lt;/i&gt;, &lt;i&gt;Silverlight 4&lt;/i&gt; and &lt;i&gt;MONO 2.6.4&lt;/i&gt;. &lt;/span&gt;&lt;br /&gt;Therefore, you can easily implement e.g. the communication between Windows Phone 7 and a standalone desktop application.&lt;br /&gt;The framework can be downloaded from&amp;nbsp;&lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/-QWr7anVFtSY/TqCF9rYb3eI/AAAAAAAABQs/R5F_eXeG8i4/s1600/EneterComponents.gif" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="278" src="http://3.bp.blogspot.com/-QWr7anVFtSY/TqCF9rYb3eI/AAAAAAAABQs/R5F_eXeG8i4/s640/EneterComponents.gif" width="640" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Interprocess Communication&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The communication between applications can be realized by various protocols or mechanisms. The right one depends on particular requirements. E.g. Are communicating applications on one machine? Are there any restrictions (e.g. Silverlight)? &lt;br /&gt;The framework allows to implement the communication via:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;Shared Memory&lt;/i&gt; - for the very fast communication between processes running on the same machine (faster than Named Pipes)&lt;/li&gt;&lt;li&gt;&amp;nbsp;&lt;i&gt;Named Pipes&lt;/i&gt; - for the communication between processes running on the same machine&lt;/li&gt;&lt;li&gt;&amp;nbsp;&lt;i&gt;TCP&lt;/i&gt; - for the communication between processes running on different machines.&lt;/li&gt;&lt;li&gt;&amp;nbsp;&lt;i&gt;HTTP&lt;/i&gt; - for the communication between processes running on different machines.&lt;/li&gt;&lt;li&gt;&amp;nbsp;&lt;i&gt;Silverlight Messaging&lt;/i&gt; - for the communication between Silverlight applications.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Encoding&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;Messages can be encoded with using:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;XML Serializer&lt;/i&gt; - for simple serialization of messages into XML.&lt;/li&gt;&lt;li&gt;&lt;i&gt;XML Data Contract Serializer&lt;/i&gt; - for the serialization of messages into XML using DataContract and DataMember attributes&lt;/li&gt;&lt;li&gt;&lt;i&gt;Binary Serializer&lt;/i&gt; - for the fast serialization of messages into the binary format.&lt;/li&gt;&lt;li&gt;&lt;i&gt;AES Serializer&lt;/i&gt; - for encrypting messages using Advanced Encryption Standard.&lt;/li&gt;&lt;li&gt;&lt;i&gt;Rijndael Serializer&lt;/i&gt; - for encrypting messages using Rijndael encryption.&lt;/li&gt;&lt;li&gt;&lt;i&gt;GZip Serializer&lt;/i&gt; - for compressing big messages before sending across the network.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="color: #0b5394;"&gt;The communication API is not bound to a particular protocol or encoding format, therefore your implementation stays same, does not matter what you use.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Routing Messages&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The routing functionality provides components that can be placed on the communication path to control the sending behavior. E.g. forwarding messages to subscribed receivers, forwarding messages to a different address, load balancing, etc.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;Broker&lt;/i&gt; - for sending notification messages to subscribed clients (i.e. publish-subscribe scenarios).&lt;/li&gt;&lt;li&gt;&lt;i&gt;Router&lt;/i&gt; - for re-routing messages to a different address.&lt;/li&gt;&lt;li&gt;&lt;i&gt;Dispatcher&lt;/i&gt; - for routing messages to multiple receivers (the same request processed by more services in parallel).&lt;/li&gt;&lt;li&gt;&lt;i&gt;Load Balancer&lt;/i&gt; - for distributing workload across more computers (or processes, or threads).&lt;/li&gt;&lt;li&gt;&lt;i&gt;Channel Wrapper/Unwrapper&lt;/i&gt; - for receiving various types of messages on one address (no need for long "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;if ... then&lt;/span&gt;" statements to recognize the type of received messages.)&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Reliability&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The communication across the network is typically less reliable as a local call performed inside the application. The network connection can be interrupted, or the receiving application can be temporarily unavailable. If your communication scenario requires to overcome these issues, the framework provides the following functionality:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;Monitoring of the connection availability&lt;/i&gt; - for early detection of a disconnection.&lt;/li&gt;&lt;li&gt;&lt;i&gt;Buffering of sent messages in case of a disconnection and automatic reconnect&lt;/i&gt; - for overcoming short disconnections e.g. caused by an unstable network.&lt;/li&gt;&lt;li&gt;&lt;i&gt;Acknowledged messages&lt;/i&gt; - for confirmation if the message was delivered or not.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Security&lt;/b&gt;&lt;/span&gt;&lt;i&gt; &lt;/i&gt;&lt;br /&gt;The communication across the network is very easy to be observed and confidential data can be acquired by unauthorized persons. Therefore you may&lt;i&gt; &lt;/i&gt;want to protect your data during the communication.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;HTTPS&lt;/i&gt;, &lt;i&gt;SSL&lt;/i&gt; and fast symetric encryption by using &lt;i&gt;AES&lt;/i&gt; or &lt;i&gt;Rijndael serializers&lt;/i&gt;.&lt;/li&gt;&lt;/ul&gt;If you are interested in more technical details about the framework, you can visit &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;Eneter Online Info&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Enjoy the third version.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-9088445697137988651?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/9088445697137988651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2011/10/eneter-messaging-framework-30.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/9088445697137988651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/9088445697137988651'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2011/10/eneter-messaging-framework-30.html' title='Eneter Messaging Framework 3.0'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-QWr7anVFtSY/TqCF9rYb3eI/AAAAAAAABQs/R5F_eXeG8i4/s72-c/EneterComponents.gif' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-7701686049615429635</id><published>2011-05-22T18:14:00.005+02:00</published><updated>2011-07-19T21:25:16.118+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Independent Startup Order of Communicating Applications</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; A simple example showing how to implement the communication where the client application can start to communicate before the service application is running.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;Typically, the startup order matters in the interprocess communication. It means, the client application assumes, that the service application is running and is ready to communicate. This behavior does not have to be a problem for systems, where the service is running the most of the time and clients start and stop regularly.&lt;br /&gt;But for systems consisting of more applications running on separate machines and starting approximately at the same time, this behavior causes, that somebody (or something) must start the system in a defined order, what complicates the life and makes the startup error prone.&lt;br /&gt;&lt;br /&gt;The example bellow implements a simple client-service communication where communicating applications can start independently from each other and the client can start to communicate even before the service is able to receive messages.&lt;br /&gt;&lt;br /&gt;The example is based on the &lt;span style="color: #660000;"&gt;Eneter Messaging Framework 2.0&lt;/span&gt; that provides components for various communication scenarios.&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net&lt;/a&gt;. The online help for developers can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Buffered Messaging&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;To implement the independent startup order behavior, we will use &lt;span style="color: #660000;"&gt;Buffered Messaging&lt;/span&gt; from the Eneter Messaging Framework.&lt;br /&gt;In case, the receiving application is not connected, the Buffered Messaging automatically tries to open the connection and meanwhile stores sent messages into the buffer. Then, when the connection is open, it sends the stored messages to the receiver.&lt;br /&gt;&lt;br /&gt;In our independent startup order scenario, if the client starts before the service and sends some message, the message is stored in the buffer. Then, when the service is started and the connection is open, the message from the buffer is sent to the service.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-l9gthLbmqQs/TiXZ3GSUIGI/AAAAAAAABMU/lfz3ReFmA80/s1600/IndependendStartupWithBufferedMessaging.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="138" src="http://3.bp.blogspot.com/-l9gthLbmqQs/TiXZ3GSUIGI/AAAAAAAABMU/lfz3ReFmA80/s640/IndependendStartupWithBufferedMessaging.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-De_zoUK7PZI/Tdk1OQdBkSI/AAAAAAAABFs/JcM6T9M3k54/s1600/IndependendStartupWithBufferedMessaging.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Service Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The service application is a simple console application communicating via TCP and returning the time.&lt;br /&gt;The whole implementation is very simple.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace TimeService&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        // The message receiver.&lt;br /&gt;        // It receives 'string' and responses 'DateTime'.&lt;br /&gt;        // Note: the 'string' is not used in this example.&lt;br /&gt;        static IDuplexTypedMessageReceiver&amp;lt;DateTime, string&amp;gt; myReceiver;&lt;br /&gt;&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Create TCP based messaging.&lt;br /&gt;            IMessagingSystemFactory aTcpMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel anInputChannel = &lt;br /&gt;                aTcpMessaging.CreateDuplexInputChannel("tcp://127.0.0.1:7083/");&lt;br /&gt;&lt;br /&gt;            // Create typed message receiver.&lt;br /&gt;            IDuplexTypedMessagesFactory aTypedMessagesFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            myReceiver = aTypedMessagesFactory.CreateDuplexTypedMessageReceiver&amp;lt;DateTime, string&amp;gt;();&lt;br /&gt;            myReceiver.MessageReceived += OnMessageReceived;&lt;br /&gt;&lt;br /&gt;            // Attach the receiver to the channel and start listening.&lt;br /&gt;            myReceiver.AttachDuplexInputChannel(anInputChannel);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("The service is listening.");&lt;br /&gt;            Console.WriteLine("Press Enter to stop.");&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&gt;            myReceiver.DetachDuplexInputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        static void OnMessageReceived(object sender, TypedRequestReceivedEventArgs&amp;lt;string&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // Process the incoming request:&lt;br /&gt;            // Just return the current time.&lt;br /&gt;            myReceiver.SendResponseMessage(e.ResponseReceiverId, DateTime.Now);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Client Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The client application is a simple application using the service to retrieve the exact time.&lt;br /&gt;The client application can start and can request the time before the service application is running.&lt;br /&gt;In such case, the request is stored in the buffer. Then, when the service is ready, the request is delivered and the service responses the time.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Try the following scenario:&lt;/b&gt;&lt;br /&gt;1. Start the client application.&lt;br /&gt;2. Invoke the request to get the exact time.&lt;br /&gt;3. Wait few seconds and start the service application.&lt;br /&gt;4. The client displays the time from the service.&lt;br /&gt;&lt;br /&gt;The implementation is very simple.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.Composites.BufferedMessagingComposit;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace TimeClient&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        // The message sender.&lt;br /&gt;        // It sends 'string' and gets 'DateTime' as the response.&lt;br /&gt;        // Note: the 'string' is not used in this example.&lt;br /&gt;        IDuplexTypedMessageSender&amp;lt;DateTime, string&amp;gt; mySender;&lt;br /&gt;&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create TCP based messaging.&lt;br /&gt;            IMessagingSystemFactory aTcpMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Create the buffered messaging.&lt;br /&gt;            // If the connection is not available, the buffered messaging tries to reconnect&lt;br /&gt;            // and meanwhile stores sent messages to the buffer.&lt;br /&gt;            // Then, when reconnected, it sends sent messages to the receiver.&lt;br /&gt;            // The following buffered messaging is based on TCP messaging&lt;br /&gt;            // and can work offline 1 minute.&lt;br /&gt;            IMessagingSystemFactory aBufferedMessaging = &lt;br /&gt;                new BufferedMessagingFactory(aTcpMessaging, TimeSpan.FromMinutes(1));&lt;br /&gt;&lt;br /&gt;            IDuplexOutputChannel anOutputChannel = &lt;br /&gt;                aBufferedMessaging.CreateDuplexOutputChannel("tcp://127.0.0.1:7083/");&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            // Create the message sender.&lt;br /&gt;            IDuplexTypedMessagesFactory aTypedMessagesFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            mySender = aTypedMessagesFactory.CreateDuplexTypedMessageSender&amp;lt;DateTime, string&amp;gt;();&lt;br /&gt;            mySender.ResponseReceived += OnResponseReceived;&lt;br /&gt;&lt;br /&gt;            // Attach the output channel and be able to send requests and receive&lt;br /&gt;            // response messages.&lt;br /&gt;            mySender.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Correctly close the connection.&lt;br /&gt;            mySender.DetachDuplexOutputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void RequestServiceTimeButton_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Invoke the request to get the current time from the service.&lt;br /&gt;            mySender.SendRequestMessage("not used");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OnResponseReceived(object sender, TypedResponseReceivedEventArgs&amp;lt;DateTime&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                // Display the time returned from the service.&lt;br /&gt;                // Note: The response does not come in the UI thread, therefore&lt;br /&gt;                //       it must be transfered to UI thread.&lt;br /&gt;                DateTime aTime = e.ResponseMessage;&lt;br /&gt;                InvokeInUIThread(() =&amp;gt; ServiceTimeTextBox.Text = aTime.ToString());&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Helper method to invoke the given delegate&lt;br /&gt;        // in the UI thread.&lt;br /&gt;        private void InvokeInUIThread(Action action)&lt;br /&gt;        {&lt;br /&gt;            if (InvokeRequired)&lt;br /&gt;            {&lt;br /&gt;                Invoke(action);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                action();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And here are communicating applications&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/--5s6wv4haHw/TiXaA4QBQuI/AAAAAAAABMY/wReK1fRZq0Y/s1600/IndependentStatupApplications.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/--5s6wv4haHw/TiXaA4QBQuI/AAAAAAAABMY/wReK1fRZq0Y/s1600/IndependentStatupApplications.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-Mtuupc_drzk/TdkZhZujg1I/AAAAAAAABFk/JHvybgIL6q0/s1600/IndependentStatupApplications.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-7701686049615429635?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/7701686049615429635/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2011/05/intependent-startup-order-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/7701686049615429635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/7701686049615429635'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2011/05/intependent-startup-order-of.html' title='Independent Startup Order of Communicating Applications'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-l9gthLbmqQs/TiXZ3GSUIGI/AAAAAAAABMU/lfz3ReFmA80/s72-c/IndependendStartupWithBufferedMessaging.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-1845434415546770665</id><published>2011-05-15T16:51:00.005+02:00</published><updated>2011-07-19T21:23:02.397+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Service Listening to TCP, HTTP and Named Pipe at the same Time</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; A simple example showing how to implement a service listening to TCP, HTTP and Named Pipe at the same time.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;The example below implements a simple service that is able to receive requests via TCP, HTTP and Named Pipe. Therefore, the service can be available for clients using different communications. E.g. Windows Phone 7 environment supports only HTTP.&lt;br /&gt;&lt;br /&gt;The example is based on the &lt;span style="color: #660000;"&gt;Eneter Messaging Framework 2.0&lt;/span&gt; that provides components for various communication scenarios.&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net&lt;/a&gt;. The online help for developers can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Multiple Listening&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;To implement the multiple listener, we will use the Dispatcher component from the &lt;span style="color: #660000;"&gt;Eneter Messaging Framework&lt;/span&gt;.&lt;br /&gt;The Dispatcher receives messages from all attached input channels and forwards them to all attached output channels.&lt;br /&gt;In our scenario, the dispatcher will have three input channels (TCP, HTTP and Named Pipe) and only one output channel (local channel to the message receiver).&lt;br /&gt;So, if a message is received e.g. via the TCP input channel, the dispatcher will forward it through the output channel to the typed message receiver. The typed message receiver then notifies the user code implementing the service.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-tYy8AW4CZTg/TiXZINbGZ4I/AAAAAAAABMM/guJqdNcRQKo/s1600/MultilisteningService.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="146" src="http://1.bp.blogspot.com/-tYy8AW4CZTg/TiXZINbGZ4I/AAAAAAAABMM/guJqdNcRQKo/s640/MultilisteningService.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Multiple Listening Service Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The service is implemented as a simple console application. The most important part is using of the dispatcher component for the multiple listening (TCP, HTTP and Named Pipe).&lt;br /&gt;Since the service listens also to HTTP, you must execute it under sufficient user rights. (I recommend administrator for the debug purposes.)&lt;br /&gt;The whole implementation is very simple.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.HttpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.NamedPipeMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.SynchronousMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.Dispatcher;&lt;br /&gt;&lt;br /&gt;namespace MultiReceivingService&lt;br /&gt;{&lt;br /&gt;    public class RequestData&lt;br /&gt;    {&lt;br /&gt;        public int Number1 { get; set; }&lt;br /&gt;        public int Number2 { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        // Receiver receiving 'RequestData' and responding 'int'.&lt;br /&gt;        // Note: Duplex typed message receiver can receive messages of specified type&lt;br /&gt;        //       and send response messages of specified type.&lt;br /&gt;        private static IDuplexTypedMessageReceiver&amp;lt;int, RequestData&amp;gt; myReceiver;&lt;br /&gt;&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Create local messaging connecting the dispatcher with the receiver.&lt;br /&gt;            IMessagingSystemFactory aLocalMessaging = new SynchronousMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel aLocalInputChannel =&lt;br /&gt;                aLocalMessaging.CreateDuplexInputChannel("MyLocalAddress");&lt;br /&gt;&lt;br /&gt;            IDuplexTypedMessagesFactory aTypedMessagesFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            myReceiver = aTypedMessagesFactory.CreateDuplexTypedMessageReceiver&amp;lt;int, RequestData&amp;gt;();&lt;br /&gt;            myReceiver.MessageReceived += OnMessageReceived;&lt;br /&gt;&lt;br /&gt;            // Attach the local input channel to the receiver and start to receive messages.&lt;br /&gt;            myReceiver.AttachDuplexInputChannel(aLocalInputChannel);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            // Create messaging using HTTP.&lt;br /&gt;            IMessagingSystemFactory anHttpMessaging = new HttpMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel anHttpInputChannel =&lt;br /&gt;                anHttpMessaging.CreateDuplexInputChannel("http://127.0.0.1:8035/MyService/");&lt;br /&gt;&lt;br /&gt;            // Create messaging using TCP.&lt;br /&gt;            IMessagingSystemFactory aTcpMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel aTcpInputChannel =&lt;br /&gt;                aTcpMessaging.CreateDuplexInputChannel("tcp://127.0.0.1:8036/");&lt;br /&gt;&lt;br /&gt;            // Create messaging using Named Pipe.&lt;br /&gt;            // Note: Do not use '/' at the end of the named pipe address.&lt;br /&gt;            IMessagingSystemFactory aPipeMessaging = new NamedPipeMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel aPipeInputChannel =&lt;br /&gt;                aPipeMessaging.CreateDuplexInputChannel("net.pipe://127.0.0.1/MyService");&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            // Create dispatcher that will receive messages via HTTP, TCP and Named Pipe&lt;br /&gt;            // and forward them to the local address "MyLocalAddress" -&amp;gt; i.e. to our receiver.&lt;br /&gt;            IDuplexDispatcherFactory aDispatcherFactory = new DuplexDispatcherFactory(aLocalMessaging);&lt;br /&gt;            IDuplexDispatcher aDispatcher = aDispatcherFactory.CreateDuplexDispatcher();&lt;br /&gt;            aDispatcher.AddDuplexOutputChannel("MyLocalAddress");&lt;br /&gt;&lt;br /&gt;            aDispatcher.AttachDuplexInputChannel(anHttpInputChannel);&lt;br /&gt;            Console.WriteLine("Listening to HTTP.");&lt;br /&gt;&lt;br /&gt;            aDispatcher.AttachDuplexInputChannel(aTcpInputChannel);&lt;br /&gt;            Console.WriteLine("Listening to TCP.");&lt;br /&gt;&lt;br /&gt;            aDispatcher.AttachDuplexInputChannel(aPipeInputChannel);&lt;br /&gt;            Console.WriteLine("Listening to Named Pipe.");&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("To stop the service press enter ...");&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&gt;            // Stop listening and detach all input channels.&lt;br /&gt;            aDispatcher.DetachDuplexInputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // The handler called when a message is received.&lt;br /&gt;        static void OnMessageReceived(object sender, TypedRequestReceivedEventArgs&amp;lt;RequestData&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                int aResult = e.RequestMessage.Number1 + e.RequestMessage.Number2;&lt;br /&gt;                Console.WriteLine("{0} + {1} = {2}", e.RequestMessage.Number1, e.RequestMessage.Number2, aResult);&lt;br /&gt;&lt;br /&gt;                // Send the result back to the client.&lt;br /&gt;                myReceiver.SendResponseMessage(e.ResponseReceiverId, aResult);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Client Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The client is a simple windows form application using the service to calculate two numbers provided by the user. The client can communicate with the service via TCP, HTTP or Named Pipe.&lt;br /&gt;Since the service application is executed under administrator user rights, the named pipe client must also be executed under same rights. (HTTP and TCP clients do not have to run under administrator user rights.) &lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace TcpClient&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        // Structure of 2 numbers that will be sent to&lt;br /&gt;        // the service to be calculated.&lt;br /&gt;        public class RequestData&lt;br /&gt;        {&lt;br /&gt;            public int Number1 { get; set; }&lt;br /&gt;            public int Number2 { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Sender sending 'RequestData' and receiving 'int'.&lt;br /&gt;        // Note: Duplex typed message sender can send messages of specified type&lt;br /&gt;        //       and receive response messages of specified type.&lt;br /&gt;        private static IDuplexTypedMessageSender&amp;lt;int, RequestData&amp;gt; mySender;&lt;br /&gt;&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create messaging using TCP.&lt;br /&gt;            IMessagingSystemFactory aTcpMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexOutputChannel anOutputChannel =&lt;br /&gt;                aTcpMessaging.CreateDuplexOutputChannel("tcp://127.0.0.1:8036/");&lt;br /&gt;&lt;br /&gt;            //// Create messaging using HTTP.&lt;br /&gt;            //IMessagingSystemFactory anHttpMessaging = new HttpMessagingSystemFactory();&lt;br /&gt;            //IDuplexOutputChannel anOutputChannel = &lt;br /&gt;            //    anHttpMessaging.CreateDuplexOutputChannel("http://127.0.0.1:8035/MyService/");&lt;br /&gt;&lt;br /&gt;            //// Create messaging using Named Pipe.&lt;br /&gt;            //// Note: Do not use '/' at the end of the named pipe address.&lt;br /&gt;            //IMessagingSystemFactory aNamedPipeMessaging = new NamedPipeMessagingSystemFactory();&lt;br /&gt;            //IDuplexOutputChannel anOutputChannel =&lt;br /&gt;            //    aNamedPipeMessaging.CreateDuplexOutputChannel("net.pipe://127.0.0.1/MyService");&lt;br /&gt;&lt;br /&gt;            // Create the sender, that sends 'RequestData' and receives 'int'.&lt;br /&gt;            IDuplexTypedMessagesFactory aTypedMessagesFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            mySender = aTypedMessagesFactory.CreateDuplexTypedMessageSender&amp;lt;int, RequestData&amp;gt;();&lt;br /&gt;&lt;br /&gt;            // Register the handler receiving the result from the service.&lt;br /&gt;            mySender.ResponseReceived += OnResponseReceived;&lt;br /&gt;&lt;br /&gt;            // Attach the TCP duplex output channel and be able to send messages&lt;br /&gt;            // and receive response messages.&lt;br /&gt;            mySender.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            mySender.DetachDuplexOutputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void CalculateButton_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Create the message.&lt;br /&gt;            RequestData aRequestData = new RequestData();&lt;br /&gt;            aRequestData.Number1 = int.Parse(Number1TextBox.Text);&lt;br /&gt;            aRequestData.Number2 = int.Parse(Number2TextBox.Text);&lt;br /&gt;&lt;br /&gt;            // Send the message to the service.&lt;br /&gt;            mySender.SendRequestMessage(aRequestData);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // When a result from the service is received, display it.&lt;br /&gt;        private void OnResponseReceived(object sender, TypedResponseReceivedEventArgs&amp;lt;int&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                // Display the result of the calculation.&lt;br /&gt;                // Note: The response message does not come in the UI thread.&lt;br /&gt;                //       Therefore, do not forget to route it if you touch UI controls.&lt;br /&gt;                InvokeInUIThread(() =&amp;gt; ResultTextBox.Text = e.ResponseMessage.ToString());&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Helper executing the given delegate in the UI thread.&lt;br /&gt;        private void InvokeInUIThread(Action action)&lt;br /&gt;        {&lt;br /&gt;            // If we are not in the UI thread then we must synchronize &lt;br /&gt;            // via the invoke mechanism.&lt;br /&gt;            if (InvokeRequired)&lt;br /&gt;            {&lt;br /&gt;                Invoke(action);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                action();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And here are communicating applications.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-RShgqw1JCy0/TiXZfwCblgI/AAAAAAAABMQ/0aGB2k9y8Co/s1600/MultipleServiceRunningApplications.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="552" src="http://2.bp.blogspot.com/-RShgqw1JCy0/TiXZfwCblgI/AAAAAAAABMQ/0aGB2k9y8Co/s640/MultipleServiceRunningApplications.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-1845434415546770665?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/1845434415546770665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2011/05/service-listening-to-tcp-http-and-named.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/1845434415546770665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/1845434415546770665'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2011/05/service-listening-to-tcp-http-and-named.html' title='Service Listening to TCP, HTTP and Named Pipe at the same Time'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-tYy8AW4CZTg/TiXZINbGZ4I/AAAAAAAABMM/guJqdNcRQKo/s72-c/MultilisteningService.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-992812827301825897</id><published>2011-04-21T15:49:00.003+02:00</published><updated>2011-07-19T21:18:06.314+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows Phone 7'/><title type='text'>Windows Phone 7: How to Encrypt Communication with Desktop Application</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; Simple example showing how to implement encrypted communication between Windows Phone 7 and standalone .NET application.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;The example bellow implements a simple .NET application as a service and a Windows Phone 7 application as a client. The service counts the number of words in the given text. The client then uses the service to get amount of words in the text and displays the result. &lt;br /&gt;&lt;br /&gt;The communication between the client and the service is protected by AES (Advanced Encryption Standard).&lt;br /&gt;&lt;br /&gt;Also, since the network connection does not have to be stable (e.g. weak signal), the example uses the buffered messaging. The buffered messaging detects disconnections, automatically tries to reconnect and meanwhile stores sent messages in the buffer. Then, when the connection is available again, the messages stored in the buffer are sent to the receiver.&lt;br /&gt;&lt;br /&gt;The example is based on the &lt;span style="color: #660000;"&gt;Eneter Messaging Framework 2.0&lt;/span&gt;.&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net&lt;/a&gt;. The online help for developers can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Service Application&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The service is a standalone .NET application and is responsible for the receiving of messages and counting words in the given text.&lt;br /&gt;Please notice, &lt;span style="color: #cc0000;"&gt;to run the HTTP listening application you must execute it under sufficient user rights&lt;/span&gt;. Otherwise the application will run, but will not listen. (The framework logs the Access denied error on the debug port.)&lt;br /&gt;The whole implementation is very simple.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Text.RegularExpressions;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.Composites;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.HttpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;&lt;br /&gt;namespace EncryptedService&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        // Receiver receiving a text message and returning back the number&lt;br /&gt;        // of words in the text message.&lt;br /&gt;        private static IDuplexTypedMessageReceiver&amp;lt;int, string&amp;gt; myReceiver;&lt;br /&gt;&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Create Http messaging.&lt;br /&gt;            IMessagingSystemFactory anUnderlyingMessaging = new HttpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // The network can be unstable. Therefore, let's use the buffered messaging with&lt;br /&gt;            // the monitor checking the connection.&lt;br /&gt;            // If the client does not ping longer than 5 seconds, the client is considered to be disconnected&lt;br /&gt;            // and its response messages are stored in the buffer.&lt;br /&gt;            // If the connection occurs within 15 seconds, the response messages are sent to the client.&lt;br /&gt;            IMessagingSystemFactory aBufferedMessaging = new BufferedMonitoredMessagingFactory(&lt;br /&gt;                anUnderlyingMessaging,&lt;br /&gt;                new XmlStringSerializer(),&lt;br /&gt;                TimeSpan.FromMilliseconds(15000),   // maximum time, the client can be offline&lt;br /&gt;                TimeSpan.FromMilliseconds(500),     // 'ping' frequency - not applicable for the service&lt;br /&gt;                TimeSpan.FromMilliseconds(5000)     // maximum time, the 'ping' message does not have to be received&lt;br /&gt;                );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            IDuplexInputChannel anInputChannel = aBufferedMessaging.CreateDuplexInputChannel("http://127.0.0.1:8035/MyService/");&lt;br /&gt;&lt;br /&gt;            // Helper: If you are interested to see the encrypted message.&lt;br /&gt;            anInputChannel.MessageReceived += OnEncryptedMessageReceived;&lt;br /&gt;&lt;br /&gt;            // Create serializer using the AES encryption.&lt;br /&gt;            // Note: The serializer is used to deserialize incoming messages&lt;br /&gt;            //       and serialize sent response messages.&lt;br /&gt;            AesSerializer aSerializer = new AesSerializer("My secret password");&lt;br /&gt;&lt;br /&gt;            // Create message receiver - response sender.&lt;br /&gt;            IDuplexTypedMessagesFactory aSenderFactory = new DuplexTypedMessagesFactory(aSerializer);&lt;br /&gt;            myReceiver = aSenderFactory.CreateDuplexTypedMessageReceiver&amp;lt;int, string&amp;gt;();&lt;br /&gt;            myReceiver.MessageReceived += OnMessageReceived;&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("The service is running.");&lt;br /&gt;            Console.WriteLine("Press enter to stop ...");&lt;br /&gt;&lt;br /&gt;            // Attach the duplex input channel and start listening.&lt;br /&gt;            myReceiver.AttachDuplexInputChannel(anInputChannel);&lt;br /&gt;&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&gt;            myReceiver.DetachDuplexInputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private static void OnMessageReceived(object sender, TypedRequestReceivedEventArgs&amp;lt;string&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                // Display the incoming text message.&lt;br /&gt;                Console.WriteLine("Received message: {0}\n", e.RequestMessage);&lt;br /&gt;&lt;br /&gt;                // Calculate number of words in the string.&lt;br /&gt;                MatchCollection aWords = Regex.Matches(e.RequestMessage, @"[\S]+");&lt;br /&gt;                int aNumberOfWords = aWords.Count;&lt;br /&gt;&lt;br /&gt;                // Send back the number of words.&lt;br /&gt;                myReceiver.SendResponseMessage(e.ResponseReceiverId, aNumberOfWords);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // This is just a helper method to display the encrypted message.&lt;br /&gt;        private static void OnEncryptedMessageReceived(object sender, DuplexChannelMessageEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            string anEncryptedMessage = "";&lt;br /&gt;            byte[] anEncryptedArray = e.Message as byte[];&lt;br /&gt;            foreach (byte aByte in anEncryptedArray)&lt;br /&gt;            {&lt;br /&gt;                anEncryptedMessage += aByte.ToString("x2");&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("Encrypted Message: {0}", anEncryptedMessage);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Client Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The client is a Windows Phone 7 application and is responsible for receiving text from the user and using the service to get the number of words in the given text. Then it displays the result.&lt;br /&gt;(Notice, if you run the application from the Visual Studio, do not forget to set, that the application shall be deployed on 'Windows Phone 7 Emulator'.)&lt;br /&gt;The client application uses the assembly built for the Windows Phone 7,&amp;nbsp; Eneter.Messaging.Framework.Phone.dll.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.Composites;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.HttpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Microsoft.Phone.Controls;&lt;br /&gt;&lt;br /&gt;namespace EncryptedClientWP7&lt;br /&gt;{&lt;br /&gt;    public partial class MainPage : PhoneApplicationPage&lt;br /&gt;    {&lt;br /&gt;        // Sender sending text messages and receiving int response messages.&lt;br /&gt;        private IDuplexTypedMessageSender&amp;lt;int, string&amp;gt; mySender;&lt;br /&gt;&lt;br /&gt;        // Constructor&lt;br /&gt;        public MainPage()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            OpenConnection();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OpenConnection()&lt;br /&gt;        {&lt;br /&gt;            // Create Http messaging.&lt;br /&gt;            // Note: The default constructor routes received response&lt;br /&gt;            //       messages into the Silverlight thread.&lt;br /&gt;            //       If it is not desired, then it can be changed.&lt;br /&gt;            IMessagingSystemFactory anUnderlyingMessaging = new HttpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // The cell-phone network can be unstable.&lt;br /&gt;            // Therefore, let's use the buffered messaging and&lt;br /&gt;            // the monitor checking if the connection is still open.&lt;br /&gt;            // Create buffered messaging, that will be able to work offline 1 minute.&lt;br /&gt;            // During the offline time, the sent messages are stored in the buffer&lt;br /&gt;            // and the framework tries to reconnect.&lt;br /&gt;            IMessagingSystemFactory aBufferedMessaging = new BufferedMonitoredMessagingFactory(&lt;br /&gt;                anUnderlyingMessaging,&lt;br /&gt;                new XmlStringSerializer(),&lt;br /&gt;                TimeSpan.FromMinutes(1),            // maximum offline time&lt;br /&gt;                TimeSpan.FromMilliseconds(500),     // how often the 'ping' checking the connection is invoked&lt;br /&gt;                TimeSpan.FromMilliseconds(1000)     // maximum time, the response for the 'ping'&lt;br /&gt;                                                    // shall be received&lt;br /&gt;                );&lt;br /&gt;            IDuplexOutputChannel anOutputChannel = &lt;br /&gt;                aBufferedMessaging.CreateDuplexOutputChannel("http://127.0.0.1:8035/MyService/");&lt;br /&gt;&lt;br /&gt;            // Create serializer using the AES encryption.&lt;br /&gt;            // Note: The serializer is used to serialize sent messages and&lt;br /&gt;            //       deserialize incoming response messages.&lt;br /&gt;            //       The password must be same as on the service side.&lt;br /&gt;            AesSerializer aSerializer = new AesSerializer("My secret password");&lt;br /&gt;&lt;br /&gt;            // Create message sender - response receiver.&lt;br /&gt;            IDuplexTypedMessagesFactory aSenderFactory = new DuplexTypedMessagesFactory(aSerializer);&lt;br /&gt;            mySender = aSenderFactory.CreateDuplexTypedMessageSender&amp;lt;int, string&amp;gt;();&lt;br /&gt;            mySender.ResponseReceived += OnResponseReceived;&lt;br /&gt;&lt;br /&gt;            // Attach duplex output channel and be able to send&lt;br /&gt;            // messages and receive response messages.&lt;br /&gt;            mySender.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void PhoneApplicationPage_Unloaded(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Disconnect from the service.&lt;br /&gt;            mySender.DetachDuplexOutputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void SendButton_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Send the message.&lt;br /&gt;            // Note: The message will be serialized and encrypted by AES and&lt;br /&gt;            //       then sent to the service.&lt;br /&gt;            mySender.SendRequestMessage(TextMessage.Text);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OnResponseReceived(object sender, TypedResponseReceivedEventArgs&amp;lt;int&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                // The message is received in the Silverlight thread,&lt;br /&gt;                // so we do not have to route it to the Silverlight thread.&lt;br /&gt;                // Display the number of words.&lt;br /&gt;                Result.Text = e.ResponseMessage.ToString();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And the communicating applications are displayed here.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-oOhdAudM9Ao/TiXX677anGI/AAAAAAAABMI/5YaW1w4sVsY/s1600/WP7EncryptedCommunication.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="518" src="http://2.bp.blogspot.com/-oOhdAudM9Ao/TiXX677anGI/AAAAAAAABMI/5YaW1w4sVsY/s640/WP7EncryptedCommunication.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-992812827301825897?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/992812827301825897/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2011/04/windows-phone-7-how-to-encrypt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/992812827301825897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/992812827301825897'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2011/04/windows-phone-7-how-to-encrypt.html' title='Windows Phone 7: How to Encrypt Communication with Desktop Application'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-oOhdAudM9Ao/TiXX677anGI/AAAAAAAABMI/5YaW1w4sVsY/s72-c/WP7EncryptedCommunication.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-8665100111484600024</id><published>2011-04-03T21:39:00.003+02:00</published><updated>2011-07-19T21:11:51.549+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><title type='text'>Silverlight: How to Communicate with Desktop Application via HTTP</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; Simple example showing how to communicate between a Silverlight application and a standalone .NET application with using HTTP.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;This article is a free continuation of&amp;nbsp; &lt;a href="http://eneter.blogspot.com/2010/11/silverlight-how-to-receive-messages.html"&gt;How to Receive Messages from Desktop Application&lt;/a&gt; and &lt;a href="http://eneter.blogspot.com/2010/10/silverlight-how-to-send-message-to.html"&gt;How to Send Message to Desktop Application&lt;/a&gt; where the Silverlight application communicates with the standalone .NET application via TCP.&lt;br /&gt;In this article I would like to show how to implement the communication via HTTP.&lt;br /&gt;&lt;br /&gt;The example bellow implements a .NET application as a service and Silverlight application as a client. The service listens to text messages and responses their length.&lt;br /&gt;The client then uses the service to get the length of the given text.&lt;br /&gt;&lt;br /&gt;The implementation uses &lt;span style="color: #660000; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Eneter Messaging Framework&lt;/span&gt;.&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net/&lt;/a&gt;. The online help for developers can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Policy Server&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Same as the TCP communication, also the HTTP communication requires the policy XML file. Silverlight automatically requests this file when the application wants to connect other than the site of origin. In case of the HTTP, Silverlight requests the policy file on the root of the HTTP request. I.e. if the Silverlight application requests &lt;span style="color: #660000; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;http://127.0.0.1/MyHttpService/&lt;/span&gt;, then Silverlight asks for the policy server from the root: &lt;span style="color: #660000; font-size: small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;http://127.0.0.1/clientaccesspolicy.xml&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;If the policy file is not available or its content does not allow the communication, the HTTP request is not performed.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-MgY2J6Rr9Bw/TiXWlIe95xI/AAAAAAAABMA/rKKRbc8dBB8/s1600/SilverlightDuplexHTTPConnection.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="272" src="http://4.bp.blogspot.com/-MgY2J6Rr9Bw/TiXWlIe95xI/AAAAAAAABMA/rKKRbc8dBB8/s640/SilverlightDuplexHTTPConnection.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Service Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The service application provides the HTTP policy service for the communication with the Silverlight client. Then it implements the simple service calculating the length for the given text.&lt;br /&gt;Please notice, to run the HTTP listening application, you must execute it under sufficient user rights. Otherwise you will get an exception.&lt;br /&gt;&lt;br /&gt;The whole implemetation is very simple.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.HttpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;&lt;br /&gt;namespace LengthService&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        // Receiver receiving messages of type string and responding int.&lt;br /&gt;        static private IDuplexTypedMessageReceiver&amp;lt;int, string&amp;gt; myReceiver;&lt;br /&gt;&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Start Http Policy Server&lt;br /&gt;            // Note: Http policy server must be initialized to the root.&lt;br /&gt;            HttpPolicyServer aPolicyServer = new HttpPolicyServer("http://127.0.0.1:8034/");&lt;br /&gt;            aPolicyServer.StartPolicyServer();&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("Http Policy Server is running.");&lt;br /&gt;&lt;br /&gt;            // Create Http messaging.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new HttpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Create the input channel that is able to&lt;br /&gt;            // receive messages and send back response messages.&lt;br /&gt;            IDuplexInputChannel anInputChannel = &lt;br /&gt;                aMessaging.CreateDuplexInputChannel("http://127.0.0.1:8034/MyService/");&lt;br /&gt;&lt;br /&gt;            // Create message receiver - response sender.&lt;br /&gt;            // It receives 'string' and responses 'int'.&lt;br /&gt;            IDuplexTypedMessagesFactory aSenderFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            myReceiver = aSenderFactory.CreateDuplexTypedMessageReceiver&amp;lt;int, string&amp;gt;();&lt;br /&gt;            myReceiver.MessageReceived += OnMessageReceived;&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("The service is listening to Http.");&lt;br /&gt;            Console.WriteLine("Press Enter to stop the service.\n");&lt;br /&gt;&lt;br /&gt;            // Attach the duplex input channel and start listening.&lt;br /&gt;            myReceiver.AttachDuplexInputChannel(anInputChannel);&lt;br /&gt;&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&gt;            myReceiver.DetachDuplexInputChannel();&lt;br /&gt;            aPolicyServer.StopPolicyServer();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        static private void OnMessageReceived(object sender,&lt;br /&gt;            TypedRequestReceivedEventArgs&amp;lt;string&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                int aLength = e.RequestMessage.Length;&lt;br /&gt;&lt;br /&gt;                Console.WriteLine("Received string: {0}; Responded length: {1}",&lt;br /&gt;                    e.RequestMessage, aLength);&lt;br /&gt;&lt;br /&gt;                // Response the length of the string.&lt;br /&gt;                myReceiver.SendResponseMessage(e.ResponseReceiverId, aLength);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Silverlight Client Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The client application uses the service to get the length of the given text.&lt;br /&gt;The client application uses the assembly built for Silverlight, &lt;span style="color: #660000; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Eneter.Messaging.Framework.Silverlight.dll&lt;/span&gt;.&lt;br /&gt;The implementation is very simple.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System.Windows;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.HttpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;&lt;br /&gt;namespace LengthClient&lt;br /&gt;{&lt;br /&gt;    public partial class MainPage : UserControl&lt;br /&gt;    {&lt;br /&gt;        // Sender sending messages of type string and&lt;br /&gt;        // receiving responses of type int.&lt;br /&gt;        private IDuplexTypedMessageSender&amp;lt;int, string&amp;gt; mySender;&lt;br /&gt;&lt;br /&gt;        public MainPage()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            OpenConnection();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OpenConnection()&lt;br /&gt;        {&lt;br /&gt;            // Create HTTP messaging with default parameters.&lt;br /&gt;            // Note: The default constructor routes received response&lt;br /&gt;            //       messages into the Silverlight thread.&lt;br /&gt;            //       If it is not desired, then it can be changed.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new HttpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            IDuplexOutputChannel anOutputChannel =&lt;br /&gt;                aMessaging.CreateDuplexOutputChannel("http://127.0.0.1:8034/MyService/");&lt;br /&gt;&lt;br /&gt;            // Create message sender - response receiver.&lt;br /&gt;            IDuplexTypedMessagesFactory aSenderFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            mySender = aSenderFactory.CreateDuplexTypedMessageSender&amp;lt;int, string&amp;gt;();&lt;br /&gt;            mySender.ResponseReceived += OnResponseReceived;&lt;br /&gt;&lt;br /&gt;            // Attach duplex output channel and be able to send messages&lt;br /&gt;            // and receive response messages.&lt;br /&gt;            mySender.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void UserControl_Unloaded(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            mySender.DetachDuplexOutputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void GetLengthButton_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Send the user text to the service.&lt;br /&gt;            // Service will response the length of the text.&lt;br /&gt;            mySender.SendRequestMessage(UserText.Text);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OnResponseReceived(object sender, TypedResponseReceivedEventArgs&amp;lt;int&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                int aResult = e.ResponseMessage;&lt;br /&gt;&lt;br /&gt;                // Display the response message.&lt;br /&gt;                // The response message is the length of the text.&lt;br /&gt;                ReceivedLength.Text = aResult.ToString();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And here are communicating applications.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-NOeZ8xHR10Q/TiXW0ge3fPI/AAAAAAAABME/fiWjgcfOuOM/s1600/SilverlightLengthServiceClientHTTP.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="298" src="http://2.bp.blogspot.com/-NOeZ8xHR10Q/TiXW0ge3fPI/AAAAAAAABME/fiWjgcfOuOM/s640/SilverlightLengthServiceClientHTTP.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I hope, you found the article useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-8665100111484600024?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/8665100111484600024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2011/04/silverlight-how-to-communicate-with.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/8665100111484600024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/8665100111484600024'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2011/04/silverlight-how-to-communicate-with.html' title='Silverlight: How to Communicate with Desktop Application via HTTP'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-MgY2J6Rr9Bw/TiXWlIe95xI/AAAAAAAABMA/rKKRbc8dBB8/s72-c/SilverlightDuplexHTTPConnection.gif' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-8804040289301966543</id><published>2011-03-27T20:34:00.006+02:00</published><updated>2011-03-27T20:52:15.061+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Windows Phone 7'/><title type='text'>Windows Phone 7: How to Communicate with Desktop Application</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; Simple example showing how to implement the communication from Windows Phone 7 to the standalone .NET application with using HTTP.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;The example bellow implements a simple .NET application as a service and Windows Phone 7 application as a client. The service calculates two numbers and returns the result. The Windows Phone 7 client then uses the service to perform the calculation and displays the result.&lt;br /&gt;&lt;br /&gt;It is typical for the cell-phone, that the network connection does not have to be stable. The signal can get weak or can be temporarily lost.&lt;br /&gt;The good application should be able to handle this situation and should not stop to work.&lt;br /&gt;&lt;br /&gt;The example bellow uses Eneter Messaging Framework, that allows to setup the communication that detects disconnections, automatically tries to reconnect and meanwhile stores sent messages in the buffer. Then, when the connection is available again, the messages stored in the buffer are sent to the receiver.&lt;br /&gt;&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net&lt;/a&gt;. The online help for developers can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Service Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The service .NET application is responsible for the calculation of two numbers and for the responding of results. The whole implementation is very simple.&lt;br /&gt;Please notice, to run the HTTP listening application you must execute it under sufficient user rights. Otherwise the application will run, but will not listen. (The framework logs the Access denied error on the debug port.)&lt;br /&gt;For the debugging purposes, I recommend to execute it under administrator rights. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.Composites;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.HttpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;&lt;br /&gt;namespace CalculatorService&lt;br /&gt;{&lt;br /&gt;    // The message transferring numbers to be calculated.&lt;br /&gt;    public class RequestMsg&lt;br /&gt;    {&lt;br /&gt;        public int Number1;&lt;br /&gt;        public int Number2;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        // Receiver receiving requests to calculate two numbers and responding the result.&lt;br /&gt;        static private IDuplexTypedMessageReceiver&amp;lt;int, RequestMsg&amp;gt; myReceiver;&lt;br /&gt;&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Create Http messaging.&lt;br /&gt;            IMessagingSystemFactory anUnderlyingMessaging = new HttpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // The network can be unstable. Therefore, let's use the buffered messaging monitoring the connection&lt;br /&gt;            // and with automatic reconnect in case of the disconnection.&lt;br /&gt;            // If the client does not ping longer than 5 seconds, the client is considered to be disconnected&lt;br /&gt;            // and its response messages are stored in the buffer.&lt;br /&gt;            // If the connection occurs within 15 seconds, the response messages are sent to the client.&lt;br /&gt;            IMessagingSystemFactory aBufferedMessaging = new BufferedMonitoredMessagingFactory(&lt;br /&gt;                anUnderlyingMessaging,&lt;br /&gt;                new XmlStringSerializer(),&lt;br /&gt;                TimeSpan.FromMilliseconds(15000),   // maximum time, the client can be offline&lt;br /&gt;                TimeSpan.FromMilliseconds(500),     // 'ping' frequency - this is not applicable for the receiver&lt;br /&gt;                TimeSpan.FromMilliseconds(5000)     // maximum time, the 'ping' message does not have to be received&lt;br /&gt;                );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            IDuplexInputChannel anInputChannel = aBufferedMessaging.CreateDuplexInputChannel("http://127.0.0.1:8034/Calculator/");&lt;br /&gt;&lt;br /&gt;            // Create message receiver - response sender.&lt;br /&gt;            IDuplexTypedMessagesFactory aSenderFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            myReceiver = aSenderFactory.CreateDuplexTypedMessageReceiver&amp;lt;int, RequestMsg&amp;gt;();&lt;br /&gt;            myReceiver.MessageReceived += OnMessageReceived;&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("Calculator service is listening to Http. Press enter to stop listening ...");&lt;br /&gt;&lt;br /&gt;            // Attach the duplex input channel and start listening&lt;br /&gt;            // on the specified address.&lt;br /&gt;            myReceiver.AttachDuplexInputChannel(anInputChannel);&lt;br /&gt;&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&gt;            myReceiver.DetachDuplexInputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // The method is called when a request is received.&lt;br /&gt;        static private void OnMessageReceived(object sender, TypedRequestReceivedEventArgs&amp;lt;RequestMsg&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // Calculate incoming 2 numbers.&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                int aResult = e.RequestMessage.Number1 + e.RequestMessage.Number2;&lt;br /&gt;&lt;br /&gt;                Console.WriteLine("{0} + {1} = {2}", e.RequestMessage.Number1, e.RequestMessage.Number2, aResult);&lt;br /&gt;&lt;br /&gt;                // Send the result back.&lt;br /&gt;                myReceiver.SendResponseMessage(e.ResponseReceiverId, aResult);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Client Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The Windows Phone 7 client application sends requests to calculate two numbers and displays results.&lt;br /&gt;If the connection is lost, the messages are buffered and messaging system tries to automatically reconnect.&lt;br /&gt;Then, if reconnected, the messages stored in the buffer are sent to the receiver.&lt;br /&gt;(Notice, if you run the application from the Visual Studio, do not forget to set, that the application shall be deployed on 'Windows Phone 7 Emulator'.)&lt;br /&gt;The client application uses the assembly built for the Windows Phone 7,&amp;nbsp; Eneter.Messaging.Framework.Phone.dll.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.Composites;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.HttpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Microsoft.Phone.Controls;&lt;br /&gt;&lt;br /&gt;namespace Phone7Sender&lt;br /&gt;{&lt;br /&gt;    public partial class MainPage : PhoneApplicationPage&lt;br /&gt;    {&lt;br /&gt;        // The message transferring numbers to be calculated.&lt;br /&gt;        public class RequestMsg&lt;br /&gt;        {&lt;br /&gt;            public int Number1;&lt;br /&gt;            public int Number2;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Sender sending the request to calculate two numbers and receiving the result.&lt;br /&gt;        private IDuplexTypedMessageSender&amp;lt;int, RequestMsg&amp;gt; mySender;&lt;br /&gt;&lt;br /&gt;        // Constructor&lt;br /&gt;        public MainPage()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            OpenConnection();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OpenConnection()&lt;br /&gt;        {&lt;br /&gt;            // Create Http messaging.&lt;br /&gt;            // Note: The default constructor routes received response messages into the Silverlight thread.&lt;br /&gt;            //       If it is not desired, then it can be changed.&lt;br /&gt;            IMessagingSystemFactory anUnderlyingMessaging = new HttpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // The cell-phone connection can be unstable.&lt;br /&gt;            // Therefore, let's use the buffered messaging monitoring the connection&lt;br /&gt;            // and with automatic reconnect in case of the disconnection.&lt;br /&gt;            // Create buffered messaging, that will be able to work offline 1 minute.&lt;br /&gt;            // During the offline time, the sent messages are stored in the buffer and the framework tries&lt;br /&gt;            // to reconnect.&lt;br /&gt;            IMessagingSystemFactory aBufferedMessaging = new BufferedMonitoredMessagingFactory(&lt;br /&gt;                anUnderlyingMessaging, &lt;br /&gt;                new XmlStringSerializer(), &lt;br /&gt;                TimeSpan.FromMinutes(1),            // maximum offline time&lt;br /&gt;                TimeSpan.FromMilliseconds(500),     // how often the 'ping' checking the connection is invoked&lt;br /&gt;                TimeSpan.FromMilliseconds(1000)     // maximum time, the response for the 'ping' shall be received&lt;br /&gt;                );&lt;br /&gt;            IDuplexOutputChannel anOutputChannel = aBufferedMessaging.CreateDuplexOutputChannel("http://127.0.0.1:8034/Calculator/");&lt;br /&gt;&lt;br /&gt;            // Create message sender - response receiver.&lt;br /&gt;            IDuplexTypedMessagesFactory aSenderFactory = new DuplexTypedMessagesFactory();&lt;br /&gt;            mySender = aSenderFactory.CreateDuplexTypedMessageSender&amp;lt;int, RequestMsg&amp;gt;();&lt;br /&gt;            mySender.ResponseReceived += OnResponseReceived;&lt;br /&gt;&lt;br /&gt;            // Attach duplex output channel and be able to send messages and receive response messages.&lt;br /&gt;            mySender.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void LayoutRoot_Unloaded(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            mySender.DetachDuplexOutputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void SendButton_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Create the request message.&lt;br /&gt;            RequestMsg aMessage = new RequestMsg();&lt;br /&gt;            aMessage.Number1 = int.Parse(Number1TextBox.Text);&lt;br /&gt;            aMessage.Number2 = int.Parse(Number2TextBox.Text);&lt;br /&gt;&lt;br /&gt;            // Send the message.&lt;br /&gt;            // Note: If the connection is not available, the message will be stored in the buffer.&lt;br /&gt;            //       We have set, the application can work offline maximum 1 minute.&lt;br /&gt;            mySender.SendRequestMessage(aMessage);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OnResponseReceived(object sender, TypedResponseReceivedEventArgs&amp;lt;int&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                // The response message was routed to the Silverlight thread.&lt;br /&gt;                // Therefore, the value can be directly written to the UI control.&lt;br /&gt;                ResultTextBox.Text = e.ResponseMessage.ToString();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The following picture shows the communicating applications:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-MUygZPkL7fg/TY9-ZIwI8DI/AAAAAAAABFA/E0KXx-XHpIQ/s1600/Phone7HttpCommunication.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="442" src="http://3.bp.blogspot.com/-MUygZPkL7fg/TY9-ZIwI8DI/AAAAAAAABFA/E0KXx-XHpIQ/s640/Phone7HttpCommunication.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I hope, you found the article useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-8804040289301966543?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/8804040289301966543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2011/03/phone-7-how-to-communicate-with-desktop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/8804040289301966543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/8804040289301966543'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2011/03/phone-7-how-to-communicate-with-desktop.html' title='Windows Phone 7: How to Communicate with Desktop Application'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-MUygZPkL7fg/TY9-ZIwI8DI/AAAAAAAABFA/E0KXx-XHpIQ/s72-c/Phone7HttpCommunication.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-3777574671432384950</id><published>2011-03-27T18:33:00.009+02:00</published><updated>2011-07-19T20:46:45.988+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows Phone 7'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Mono'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Eneter Messaging Framework 2.0</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; The second version of the lightweight framework for the interprocess communication.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;The Eneter Messaging Framework is the lightweight framework intended for the communication between processes.&lt;br /&gt;The second version of the framework supports all features and API from the previous version and in addition, it comes with new features:&lt;br /&gt;&lt;br /&gt;Reliability &lt;br /&gt;&lt;ul&gt;&lt;li&gt;Monitoring of the connection&lt;/li&gt;&lt;li&gt;Buffering of sent messages in case of a disconnection and automatic reconnect&lt;/li&gt;&lt;li&gt;Acknowledged communication&lt;/li&gt;&lt;/ul&gt;Security&lt;br /&gt;&lt;ul&gt;&lt;li&gt;SSL supported for the TCP communication&lt;/li&gt;&lt;li&gt;Fast symmetric encoding of messages with AES and Rijndael&lt;/li&gt;&lt;/ul&gt;General&lt;br /&gt;&lt;ul&gt;&lt;li&gt; HTTP policy server for the HTTP communication between Silverlight and the standalone .NET application&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;The following picture summarizes possibilities of the framework:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-oMcMfM3vNUk/TiXQ2DG5U5I/AAAAAAAABL8/zGLJMeTfVtk/s1600/EneterComponents.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="258" src="http://2.bp.blogspot.com/-oMcMfM3vNUk/TiXQ2DG5U5I/AAAAAAAABL8/zGLJMeTfVtk/s640/EneterComponents.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In summary the framework covers the following main use-cases:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Interprocess Communication&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The framework enables you to implement the communication between your applications with using messages.&lt;br /&gt;&lt;br /&gt;You can use string messages or strongly typed messages. The communication can be one-way or request-response. You also can implement publish-subscribe scenarios where applications can be subscribed to receive desired notification messages from other applications.&lt;br /&gt;&lt;br /&gt;The reason why you could consider the communication via messages is, the communicating applications are loosely coupled. It means, they do not have many assumptions about each other. They just need to know the message format and the address (channel) where to send / receive the message. This reduces the maintenance effort and increases the flexibility.&lt;br /&gt;E.g. In case of messaging communication, if you add a new message to the service, the existing client applications are not affected.&lt;br /&gt;In case of Remote Procedure Call (RPC), if you add a new method to the service interface, you probably need to update clients using this interface.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Across Platform Communication&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The framework is implemented for the following platforms: .NET, Silverlight, Windows Phone 7 and Mono.&lt;br /&gt;Therefore, with using the framework you can use the same approach to connect applications running on different platforms:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Silverlight application and .Net application&lt;/li&gt;&lt;li&gt;Silverlight application and Mono application&lt;/li&gt;&lt;li&gt;Windows Phone 7 application and .Net application&lt;/li&gt;&lt;li&gt;Windows Phone 7 application and Mono application&lt;/li&gt;&lt;li&gt;.NET application and Mono application&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Reliable Communication&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The communication across the network is much less reliable as the communication on one machine. It is quite common, the network connection is interrupted or the application is not available.&lt;br /&gt;To support these scenarios, the framework provides:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;Buffered messaging with automatic reconnect&lt;/i&gt; - in case of the disconnection, the sent messages are stored in the buffer and the framework tries to reconnect. If reconnected, the messages stored in the buffer are sent to the receiver.&lt;/li&gt;&lt;li&gt;&lt;i&gt;Acknowledged messages&lt;/i&gt; - the delivery of sent messages is confirmed.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Secured Communication&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;To secure the communication, the framework allows to use HTTPS or SSL or you can just encrypt messages with fast symmetric encryption AES or Rijndael.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you are interested in more technical details, you can visit:&lt;br /&gt;&lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Release notes:&lt;br /&gt;&lt;a href="http://www.eneter.net/ReleaseNotes.htm"&gt;http://www.eneter.net/ReleaseNotes.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The full version of the framework is free for non-commercial usage and can be downloaded from:&lt;br /&gt;&lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I hope, you will enjoy the second version.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-3777574671432384950?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/3777574671432384950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2011/03/eneter-messaging-framework-20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/3777574671432384950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/3777574671432384950'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2011/03/eneter-messaging-framework-20.html' title='Eneter Messaging Framework 2.0'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-oMcMfM3vNUk/TiXQ2DG5U5I/AAAAAAAABL8/zGLJMeTfVtk/s72-c/EneterComponents.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-5553420841179418699</id><published>2010-11-06T14:35:00.003+01:00</published><updated>2011-07-19T20:43:34.020+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Silverlight: How to Receive Messages from Desktop Application</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; Simple example showing how Silverlight application can receive messages from a standalone desktop application.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The article is a free continuation of &lt;a href="http://eneter.blogspot.com/2010/10/silverlight-how-to-send-message-to.html"&gt;How to Send Message to Desktop Application&lt;/a&gt; where the Silverlight application sends a text message to the desktop application.&lt;br /&gt;Now I would like to show how the Silverlight application can receive text messages from the desktop application with using TCP connection.&lt;br /&gt;(Actually, the example bellow shows the bidirectional communication between the Silverlight application and the desktop application.)&lt;br /&gt;&lt;br /&gt;The implementation uses Eneter Messaging Framework.&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net/&lt;/a&gt;. The online help for developers can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;As mentioned in the previous article, the Silverlight communication via TCP has the following specifics:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The Silverlight framework requires the policy server.&lt;/li&gt;&lt;li&gt;The Silverlight framework allows only ports of range 4502 - 4532.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;In addition:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The Silverlight application cannot be a TCP listener.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Therefore, if the Silverlight application wants to receive messages, it must open TCP connection to the listening desktop application and receive response messages.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-cPtr9blkmrE/TiXP5yLnzyI/AAAAAAAABL0/b-4BJv5-rYM/s1600/SilverlightDuplexTcpConnection.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="272" src="http://2.bp.blogspot.com/-cPtr9blkmrE/TiXP5yLnzyI/AAAAAAAABL0/b-4BJv5-rYM/s640/SilverlightDuplexTcpConnection.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Eneter Messaging Framework supports these specifics. It contains the policy server, wraps the low-level socket communication and allows the request-response communication via duplex channels.&lt;br /&gt;The implementation is very simple.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Desktop Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The desktop application is responsible for starting the policy server, for receiving messages and for sending messages back to the Silverlight application.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Eneter.Messaging.EndPoints.StringMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace DesktopApplication&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Start the policy server to be able to communicate with silverlight.&lt;br /&gt;            myPolicyServer.StartPolicyServer();&lt;br /&gt;&lt;br /&gt;            // Create duplex message receiver.&lt;br /&gt;            // It can receive messages and also send back response messages.&lt;br /&gt;            IDuplexStringMessagesFactory aStringMessagesFactory = new DuplexStringMessagesFactory();&lt;br /&gt;            myMessageReceiver = aStringMessagesFactory.CreateDuplexStringMessageReceiver();&lt;br /&gt;            myMessageReceiver.ResponseReceiverConnected += ClientConnected;&lt;br /&gt;            myMessageReceiver.ResponseReceiverDisconnected += ClientDisconnected;&lt;br /&gt;            myMessageReceiver.RequestReceived += MessageReceived;&lt;br /&gt;&lt;br /&gt;            // Create TCP based messaging.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel aDuplexInputChannel = aMessaging.CreateDuplexInputChannel("127.0.0.1:4502");&lt;br /&gt;&lt;br /&gt;            // Attach the duplex input channel to the message receiver and start listening.&lt;br /&gt;            // Note: Duplex input channel can receive messages but also send messages back.&lt;br /&gt;            myMessageReceiver.AttachDuplexInputChannel(aDuplexInputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Close listenig.&lt;br /&gt;            // Note: If the listening is not closed, then listening threads are not ended&lt;br /&gt;            //       and the application would not be closed properly.&lt;br /&gt;            myMessageReceiver.DetachDuplexInputChannel();&lt;br /&gt;&lt;br /&gt;            myPolicyServer.StopPolicyServer();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // The method is called when a message from the client is received.&lt;br /&gt;        private void MessageReceived(object sender, StringRequestReceivedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Display received message.&lt;br /&gt;            InvokeInUIThread(() =&amp;gt;&lt;br /&gt;                {&lt;br /&gt;                    ReceivedMessageTextBox.Text = e.RequestMessage;&lt;br /&gt;                });&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // The method is called when a client is connected.&lt;br /&gt;        // The Silverlight client is connected when the client attaches the output duplex channel.&lt;br /&gt;        private void ClientConnected(object sender, ResponseReceiverEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Add the connected client to the listbox.&lt;br /&gt;            InvokeInUIThread(() =&amp;gt;&lt;br /&gt;                {&lt;br /&gt;                    ConnectedClientsListBox.Items.Add(e.ResponseReceiverId);&lt;br /&gt;                });&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // The method is called when a client is disconnected.&lt;br /&gt;        // The Silverlight client is disconnected if the web page is closed.&lt;br /&gt;        private void ClientDisconnected(object sender, ResponseReceiverEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Remove the disconnected client from the listbox.&lt;br /&gt;            InvokeInUIThread(() =&amp;gt;&lt;br /&gt;                {&lt;br /&gt;                    ConnectedClientsListBox.Items.Remove(e.ResponseReceiverId);&lt;br /&gt;                });&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void SendButton_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Send the message to all connected clients.&lt;br /&gt;            foreach (string aClientId in ConnectedClientsListBox.Items)&lt;br /&gt;            {&lt;br /&gt;                myMessageReceiver.SendResponseMessage(aClientId, MessageTextBox.Text);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Helper method to invoke some functionality in UI thread.&lt;br /&gt;        private void InvokeInUIThread(Action uiMethod)&lt;br /&gt;        {&lt;br /&gt;            // If we are not in the UI thread then we must synchronize &lt;br /&gt;            // via the invoke mechanism.&lt;br /&gt;            if (InvokeRequired)&lt;br /&gt;            {&lt;br /&gt;                Invoke(uiMethod);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                uiMethod();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private TcpPolicyServer myPolicyServer = new TcpPolicyServer();&lt;br /&gt;        private IDuplexStringMessageReceiver myMessageReceiver;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Silverlight Application&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The Silverlight application is responsible for sending text messages and for receiving response messages. (The communication with the policy server is invoked automatically by Silverlight before the connection is established.)&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System.Windows;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using Eneter.Messaging.EndPoints.StringMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace SilverlightApplication&lt;br /&gt;{&lt;br /&gt;    public partial class MainPage : UserControl&lt;br /&gt;    {&lt;br /&gt;        public MainPage()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create duplex message sender.&lt;br /&gt;            // It can send messages and also receive messages.&lt;br /&gt;            IDuplexStringMessagesFactory aStringMessagesFactory = new DuplexStringMessagesFactory();&lt;br /&gt;            myMessageSender = aStringMessagesFactory.CreateDuplexStringMessageSender();&lt;br /&gt;            myMessageSender.ResponseReceived += MessageReceived;&lt;br /&gt;&lt;br /&gt;            // Create TCP based messaging.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexOutputChannel aDuplexOutputChannel = aMessaging.CreateDuplexOutputChannel("127.0.0.1:4502");&lt;br /&gt;&lt;br /&gt;            // Attach the duplex output channel to the message sender&lt;br /&gt;            // and be able to send messages and receive messages.&lt;br /&gt;            myMessageSender.AttachDuplexOutputChannel(aDuplexOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // The method is called when a message from the desktop application is received.&lt;br /&gt;        private void MessageReceived(object sender, StringResponseReceivedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            textBox2.Text = e.ResponseMessage;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // The method is called when the button to send message is clicked.&lt;br /&gt;        private void SendMessage_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myMessageSender.SendMessage(textBox1.Text);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        private IDuplexStringMessageSender myMessageSender;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Communicating Applications&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The picture bellow shows the communicating applications. The desktop applications sent the message 'Hello Silverlight' that was received by both Silverlight clients. The first Silverlight application sent the message 'Hi Desktop' that was received by the desktop application.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-uuYn6BklIH8/TiXQDpIzHJI/AAAAAAAABL4/qLk_3_JJC6A/s1600/MessagesFromDesktopToSilverlightUI.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="378" src="http://3.bp.blogspot.com/-uuYn6BklIH8/TiXQDpIzHJI/AAAAAAAABL4/qLk_3_JJC6A/s640/MessagesFromDesktopToSilverlightUI.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_DXGM58YRkfQ/TNVNnYoum7I/AAAAAAAABDc/TMBJZAbVNQo/s1600/MessagesFromDesktopToSilverlightUI.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I hope you found the article useful. Any feedback is welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-5553420841179418699?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/5553420841179418699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/11/silverlight-how-to-receive-messages.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/5553420841179418699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/5553420841179418699'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/11/silverlight-how-to-receive-messages.html' title='Silverlight: How to Receive Messages from Desktop Application'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-cPtr9blkmrE/TiXP5yLnzyI/AAAAAAAABL0/b-4BJv5-rYM/s72-c/SilverlightDuplexTcpConnection.gif' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-8226949690858992005</id><published>2010-10-31T11:27:00.003+01:00</published><updated>2011-07-19T20:39:15.318+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Silverlight: How to Send Message to Desktop Application</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; Very simple example showing how to send a message from Silverlight application to standalone desktop application.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Introduction&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;The example bellow shows how to use Eneter Messaging Framework to send text messages from Silverlight application to standalone desktop application with using Tcp connection.&lt;br /&gt;&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net/&lt;/a&gt;. The online help for developers can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;When we want to use the Tcp conection in Silverlight, we must be aware of following specifics:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The Silverlight framework requires the policy server.&lt;/li&gt;&lt;li&gt;The Silverlight framework allows only ports of range 4502 - 4532.&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;Policy Server&lt;/b&gt;&lt;br /&gt;The Policy Server is a special service listening on the port 943. The service receives '&amp;lt;policy-file-request&amp;gt;' and responses the policy file that says who is allowed to communicate.&lt;br /&gt;&lt;br /&gt;Silverlight automatically uses this service when creates the Tcp connection. It sends the request on the port 943 and expects the policy file. If the policy server is not there or the content of the policy file does not allow the communication, the Tcp connection is not created.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-2oBGQ7VMK7U/TiXPNrRumjI/AAAAAAAABLw/dWW03H8Ccvs/s1600/SilverlightTcpConnection.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="272" src="http://4.bp.blogspot.com/-2oBGQ7VMK7U/TiXPNrRumjI/AAAAAAAABLw/dWW03H8Ccvs/s640/SilverlightTcpConnection.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Eneter Messaging Framework wraps the low-level socket communication and provides convenient API for the Tcp communication. It also provides the Policy Server for you. Therefore the implementation is very simple. See the code bellow.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Desktop Application&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The desktop application is responsible for starting the policy server and receiving messages.&lt;br /&gt;The whole implementation is here:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using Eneter.Messaging.EndPoints.StringMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace Receiver&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Start policy server enabling silverlight security to communicate via Tcp.&lt;br /&gt;            TcpPolicyServer aPolicyServer = new TcpPolicyServer();&lt;br /&gt;            aPolicyServer.StartPolicyServer();&lt;br /&gt;&lt;br /&gt;            // Create receiver of string messages.&lt;br /&gt;            IStringMessagesFactory aStringMessageReceiverFactory = new StringMessagesFactory();&lt;br /&gt;            IStringMessageReceiver aStringMessageReceiver = aStringMessageReceiverFactory.CreateStringMessageReceiver();&lt;br /&gt;            aStringMessageReceiver.MessageReceived += StringMessageReceived;&lt;br /&gt;&lt;br /&gt;            // Create Tcp listrning channel.&lt;br /&gt;            // Note: Silverlight supports only ports of range 4502 - 4532&lt;br /&gt;            IMessagingSystemFactory aTcpMessagingFactory = new TcpMessagingSystemFactory();&lt;br /&gt;            IInputChannel anInputChannel = aTcpMessagingFactory.CreateInputChannel("127.0.0.1:4502");&lt;br /&gt;&lt;br /&gt;            // Attach the input channel to the string message receiver and start listening.&lt;br /&gt;            Console.WriteLine("Receiver is listening.");&lt;br /&gt;            aStringMessageReceiver.AttachInputChannel(anInputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        static void StringMessageReceived(object sender, StringMessageEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Process incoming message.&lt;br /&gt;            Console.WriteLine(e.Message);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Silverlight Application&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The Silverlight application is responsible for sending text messages. (The communication with the policy server is invoked automatically by Silverlight before the connection is established.)&lt;br /&gt;The whole implementation is very simple:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System.Windows;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using Eneter.Messaging.EndPoints.StringMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace SilverlightApplication&lt;br /&gt;{&lt;br /&gt;    public partial class MainPage : UserControl&lt;br /&gt;    {&lt;br /&gt;        public MainPage()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create sender of string messages.&lt;br /&gt;            IStringMessagesFactory aStringMessageReceiverFactory = new StringMessagesFactory();&lt;br /&gt;            myStringMessageSender = aStringMessageReceiverFactory.CreateStringMessageSender();&lt;br /&gt;&lt;br /&gt;            // Create output channel sending via Tcp.&lt;br /&gt;            // Note1: Silverlight supports only ports of range 4502 - 4532&lt;br /&gt;            IMessagingSystemFactory aTcpMessagingFactory = new TcpMessagingSystemFactory();&lt;br /&gt;            IOutputChannel anOutputChannel = aTcpMessagingFactory.CreateOutputChannel("127.0.0.1:4502");&lt;br /&gt;&lt;br /&gt;            // Attach the output channel to the string message sender&lt;br /&gt;            // to be able to send messages via Tcp.&lt;br /&gt;            myStringMessageSender.AttachOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Send message when the button is clicked.&lt;br /&gt;        private void button1_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            string aMessage = textBox1.Text;&lt;br /&gt;            myStringMessageSender.SendMessage(aMessage);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private IStringMessageSender myStringMessageSender;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I hope you found the article useful and if you have any comments or questions feel free to ask.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-8226949690858992005?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/8226949690858992005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/10/silverlight-how-to-send-message-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/8226949690858992005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/8226949690858992005'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/10/silverlight-how-to-send-message-to.html' title='Silverlight: How to Send Message to Desktop Application'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-2oBGQ7VMK7U/TiXPNrRumjI/AAAAAAAABLw/dWW03H8Ccvs/s72-c/SilverlightTcpConnection.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-1199792793344913420</id><published>2010-10-23T19:43:00.009+02:00</published><updated>2011-07-18T23:47:55.160+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Multiple Publishers - Multiple Subscribers Communication</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; Simple example showing how to implement the communication scenario where subscribing applications can receive notification messages from more publishing applications.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The article is a free continuation of &lt;a href="http://eneter.blogspot.com/2010/10/publish-subscribe-communication.html"&gt;Public-Subscribe Communication&lt;/a&gt; where one application (publisher) sends notifications to more applications (subscribers).&lt;br /&gt;Now I would like to describe the scenario where subscribing applications need to receive notifications from more publishing applications.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The main question in this scenario is how to connect publishing applications with subscribing applications. If subscribers are connected directly to individual publishers, then we can get quickly many connections that can be difficult to manage.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_DXGM58YRkfQ/TMMP5aU1NnI/AAAAAAAABDM/fZPtgmIwsJ8/s1600/PublishSubcribeMultiple.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-Uw0CIFhULHE/TiSpjvu8tgI/AAAAAAAABKM/92xhdWqWYvk/s1600/PublishSubcribeMultiple.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="261" src="http://3.bp.blogspot.com/-Uw0CIFhULHE/TiSpjvu8tgI/AAAAAAAABKM/92xhdWqWYvk/s400/PublishSubcribeMultiple.gif" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;To reduce the complexity and number of connections, we can implement one application as Broker that will maintain registered subscribers and forward them messages from publishers. Subscribers are so connected only to the broker and do not have to handle connections with publishers. Publishers send messages only to the broker and do not have to register/unregister subscribers.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_DXGM58YRkfQ/TMMQOAOCqyI/AAAAAAAABDQ/ZOIC6OWyr54/s1600/PublishSubcribeBroker.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-aWQseVauKw0/TiSpxoelZwI/AAAAAAAABKQ/EL9t0CCnLY4/s1600/PublishSubcribeBroker.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="261" src="http://2.bp.blogspot.com/-aWQseVauKw0/TiSpxoelZwI/AAAAAAAABKQ/EL9t0CCnLY4/s400/PublishSubcribeBroker.gif" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The following example shows how to implement this scenario with using Eneter Messaging Framework.&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;. The online help for developers can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Broker&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The Broker is responsible for receiving notification messages from publishing applications and for forwarding them to all subscribed receivers.&lt;br /&gt;The implementation of broker application is really trivial with Eneter Messaging Framework.&lt;br /&gt;The whole implementation is here:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.Broker;&lt;br /&gt;&lt;br /&gt;namespace BrokerApplication&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Create the broker.&lt;br /&gt;            IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory(new XmlStringSerializer());&lt;br /&gt;            IDuplexBroker aBroker = aBrokerFactory.CreateBroker();&lt;br /&gt;&lt;br /&gt;            // Create the Input channel receiving messages via Tcp.&lt;br /&gt;            // Note: You can also choose NamedPipes or Http.&lt;br /&gt;            //       (if you choose http, do not forget to execute it with sufficient user rights)&lt;br /&gt;            IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel aBrokerInputChannel = aMessaging.CreateDuplexInputChannel("127.0.0.1:7091");&lt;br /&gt;&lt;br /&gt;            // Attach the input channel to the broker and start listening.&lt;br /&gt;            Console.WriteLine("The broker application is running.");&lt;br /&gt;            aBroker.AttachDuplexInputChannel(aBrokerInputChannel);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Publisher&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The Publisher is responsible for sending messages to the broker application. The broker application then forwards messages to subscribed receivers.&lt;br /&gt;The whole implementation is here:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.Broker;&lt;br /&gt;&lt;br /&gt;namespace Publisher&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        // Notification message 1&lt;br /&gt;        public class NotifyMsg1&lt;br /&gt;        {&lt;br /&gt;            public DateTime CurrentTime { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Notification message 2&lt;br /&gt;        public class NotifyMsg2&lt;br /&gt;        {&lt;br /&gt;            public int Number { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Notification message 3&lt;br /&gt;        public class NotifyMsg3&lt;br /&gt;        {&lt;br /&gt;            public string TextMessage { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create broker client responsible for sending messages to the broker.&lt;br /&gt;            IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory(new XmlStringSerializer());&lt;br /&gt;            myBrokerClient = aBrokerFactory.CreateBrokerClient();&lt;br /&gt;&lt;br /&gt;            // Create output channel to send messages via Tcp.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            myOutputChannel = aMessaging.CreateDuplexOutputChannel("127.0.0.1:7091");&lt;br /&gt;&lt;br /&gt;            // Attach the output channel to the broker client to be able to send messages.&lt;br /&gt;            myBrokerClient.AttachDuplexOutputChannel(myOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Correctly close the output channel.&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Note: The duplex output channel can receive response messages too.&lt;br /&gt;            //       Therefore we must close it to stop the thread receiving response messages.&lt;br /&gt;            //       If the thred is not closed then the application could not be correctly closed.&lt;br /&gt;            myBrokerClient.DetachDuplexOutputChannel();&lt;br /&gt;            myOutputChannel.CloseConnection();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Send NotifyMsg1&lt;br /&gt;        private void Notify1Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            NotifyMsg1 aMsg = new NotifyMsg1();&lt;br /&gt;            aMsg.CurrentTime = DateTime.Now;&lt;br /&gt;&lt;br /&gt;            object aSerializedMsg = mySerializer.Serialize&amp;lt;NotifyMsg1&amp;gt;(aMsg);&lt;br /&gt;&lt;br /&gt;            myBrokerClient.SendMessage("MyNotifyMsg1", aSerializedMsg);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Send NotifyMsg2&lt;br /&gt;        private void Notify2Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            NotifyMsg2 aMsg = new NotifyMsg2();&lt;br /&gt;            aMsg.Number = 12345;&lt;br /&gt;&lt;br /&gt;            object aSerializedMsg = mySerializer.Serialize&amp;lt;NotifyMsg2&amp;gt;(aMsg);&lt;br /&gt;&lt;br /&gt;            myBrokerClient.SendMessage("MyNotifyMsg2", aSerializedMsg);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Send NotifyMsg3&lt;br /&gt;        private void Notify3Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            NotifyMsg3 aMsg = new NotifyMsg3();&lt;br /&gt;            aMsg.TextMessage = "My notifying text message.";&lt;br /&gt;&lt;br /&gt;            object aSerializedMsg = mySerializer.Serialize&amp;lt;NotifyMsg3&amp;gt;(aMsg);&lt;br /&gt;&lt;br /&gt;            myBrokerClient.SendMessage("MyNotifyMsg3", aSerializedMsg);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // Broker client is used to send messages to the broker,&lt;br /&gt;        // that forwards messages to subscribers.&lt;br /&gt;        private IDuplexBrokerClient myBrokerClient;&lt;br /&gt;&lt;br /&gt;        // The output channel used by the broker client to send messages to the broker.&lt;br /&gt;        private IDuplexOutputChannel myOutputChannel;&lt;br /&gt;&lt;br /&gt;        // Serializer used to serialize notification messages.&lt;br /&gt;        // Note: It is possible to use BinarySerializer too.&lt;br /&gt;        //       In that case the messages would have to be declared in a&lt;br /&gt;        //       separate library that would be linked by subscribers too.&lt;br /&gt;        private XmlStringSerializer mySerializer = new XmlStringSerializer();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Subscriber&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The Subscriber is responsible for its registering in the broker application to receive desired notification messages.&lt;br /&gt;The whole implementation is here:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.Broker;&lt;br /&gt;&lt;br /&gt;namespace Subscriber&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        // Notification message 1&lt;br /&gt;        public class NotifyMsg1&lt;br /&gt;        {&lt;br /&gt;            public DateTime CurrentTime { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Notification message 2&lt;br /&gt;        public class NotifyMsg2&lt;br /&gt;        {&lt;br /&gt;            public int Number { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Notification message 3&lt;br /&gt;        public class NotifyMsg3&lt;br /&gt;        {&lt;br /&gt;            public string TextMessage { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create the broker client that will receive notification messages.&lt;br /&gt;            IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory(new XmlStringSerializer());&lt;br /&gt;            myBrokerClient = aBrokerFactory.CreateBrokerClient();&lt;br /&gt;            myBrokerClient.BrokerMessageReceived += OnNotificationMessageReceived;&lt;br /&gt;&lt;br /&gt;            // Create the Tcp messaging for the communication with the publisher.&lt;br /&gt;            // Note: For the interprocess communication you can use: Tcp, NamedPipes and Http.&lt;br /&gt;            IMessagingSystemFactory aMessagingFactory = new TcpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Create duplex output channel for the communication with the publisher.&lt;br /&gt;            // Note: The duplex output channel can send requests and receive responses.&lt;br /&gt;            //       In our case, the broker client will send requests to subscribe/unsubscribe&lt;br /&gt;            //       and receive notifications as response messages.&lt;br /&gt;            myOutputChannel = aMessagingFactory.CreateDuplexOutputChannel("127.0.0.1:7091");&lt;br /&gt;&lt;br /&gt;            // Attach the output channel to the broker client&lt;br /&gt;            myBrokerClient.AttachDuplexOutputChannel(myOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Correctly close the communication.&lt;br /&gt;        // Note: If the communication is not correctly closed, the thread listening to&lt;br /&gt;        //       response messages will not be closed.&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myBrokerClient.DetachDuplexOutputChannel();&lt;br /&gt;            myOutputChannel.CloseConnection();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Method processing notification messages from the publisher.&lt;br /&gt;        private void OnNotificationMessageReceived(object sender, BrokerMessageReceivedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // The notification event does not come in UI thread.&lt;br /&gt;            // Therefore, if we want to work with UI controls we must execute it in the UI thread.&lt;br /&gt;            InvokeInUIThread(() =&amp;gt;&lt;br /&gt;                {&lt;br /&gt;                    if (e.ReceivingError == null)&lt;br /&gt;                    {&lt;br /&gt;                        if (e.MessageTypeId == "MyNotifyMsg1")&lt;br /&gt;                        {&lt;br /&gt;                            NotifyMsg1 aDeserializedMsg = mySerializer.Deserialize&amp;lt;NotifyMsg1&amp;gt;(e.Message);&lt;br /&gt;                            Received1TextBox.Text = aDeserializedMsg.CurrentTime.ToString();&lt;br /&gt;                        }&lt;br /&gt;                        else if (e.MessageTypeId == "MyNotifyMsg2")&lt;br /&gt;                        {&lt;br /&gt;                            NotifyMsg2 aDeserializedMsg = mySerializer.Deserialize&amp;lt;NotifyMsg2&amp;gt;(e.Message);&lt;br /&gt;                            Received2TextBox.Text = aDeserializedMsg.Number.ToString();&lt;br /&gt;                        }&lt;br /&gt;                        else if (e.MessageTypeId == "MyNotifyMsg3")&lt;br /&gt;                        {&lt;br /&gt;                            NotifyMsg3 aDeserializedMsg = mySerializer.Deserialize&amp;lt;NotifyMsg3&amp;gt;(e.Message);&lt;br /&gt;                            Received3TextBox.Text = aDeserializedMsg.TextMessage;&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;                });&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Subscribe to notification message 1&lt;br /&gt;        private void Subscribe1Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myBrokerClient.Subscribe("MyNotifyMsg1");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Unsubscribe from notification message 1&lt;br /&gt;        private void Unsubscribe1Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Received1TextBox.Text = "";&lt;br /&gt;            myBrokerClient.Unsubscribe("MyNotifyMsg1");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Subscribe to notification message 2&lt;br /&gt;        private void Subscribe2Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myBrokerClient.Subscribe("MyNotifyMsg2");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Unsubscribe from notification message 2&lt;br /&gt;        private void Unsubscribe2Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Received2TextBox.Text = "";&lt;br /&gt;            myBrokerClient.Unsubscribe("MyNotifyMsg2");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Subscribe to notification message 3&lt;br /&gt;        private void Subscribe3Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myBrokerClient.Subscribe("MyNotifyMsg3");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Unsubscribe from notification message 3&lt;br /&gt;        private void Unsubscribe3Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Received3TextBox.Text = "";&lt;br /&gt;            myBrokerClient.Unsubscribe("MyNotifyMsg3");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Helper method to invoke some functionality in UI thread.&lt;br /&gt;        private void InvokeInUIThread(Action uiMethod)&lt;br /&gt;        {&lt;br /&gt;            // If we are not in the UI thread then we must synchronize via the invoke mechanism.&lt;br /&gt;            if (InvokeRequired)&lt;br /&gt;            {&lt;br /&gt;                Invoke(uiMethod);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                uiMethod();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // BrokerClient provides the communication with the broker.&lt;br /&gt;        private IDuplexBrokerClient myBrokerClient;&lt;br /&gt;&lt;br /&gt;        // The output channel used by the broker client to send messages to the broker.&lt;br /&gt;        private IDuplexOutputChannel myOutputChannel;&lt;br /&gt;&lt;br /&gt;        // Serializer used to sdeerialize notification messages.&lt;br /&gt;        // Note: It is possible to use BinarySerializer too.&lt;br /&gt;        //       In that case the messages would have to be declared in a&lt;br /&gt;        //       separate library that would be linked by publisher too.&lt;br /&gt;        private XmlStringSerializer mySerializer = new XmlStringSerializer();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And for the completeness, here are publishers and subscribers running together with the broker.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_DXGM58YRkfQ/TMMXBLC3AtI/AAAAAAAABDU/Bi0tNuObkyk/s1600/PublishSubscribeBrokerUI.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-vrVxAvYODMA/TiSp9ZGo1uI/AAAAAAAABKU/jT_sITvBdqQ/s1600/PublishSubscribeBrokerUI.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="302" src="http://2.bp.blogspot.com/-vrVxAvYODMA/TiSp9ZGo1uI/AAAAAAAABKU/jT_sITvBdqQ/s640/PublishSubscribeBrokerUI.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I hope, you found the article useful. If you have any comments or questions, please let me know.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-1199792793344913420?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/1199792793344913420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/10/multiple-publishers-multiple.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/1199792793344913420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/1199792793344913420'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/10/multiple-publishers-multiple.html' title='Multiple Publishers - Multiple Subscribers Communication'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-Uw0CIFhULHE/TiSpjvu8tgI/AAAAAAAABKM/92xhdWqWYvk/s72-c/PublishSubcribeMultiple.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-668820811046965870</id><published>2010-10-17T13:59:00.011+02:00</published><updated>2011-07-18T23:35:27.904+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Publish-Subscribe Communication</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; Simple example showing how to implement a communication scenario where one application sends notifications to other applications.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The scenario where one application needs to inform other applications about some particular events is very common. &lt;br /&gt;The application that wants to be informed about events subscribes to get notification messages from the publishing application. Then, when the event occurs, the publishing application notifies all subscribed applications.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-JjFmQuUPFGw/TiSiAy7okaI/AAAAAAAABJ0/sggZEbEELBk/s1600/Publish-SubscribeCommunication.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="306" src="http://4.bp.blogspot.com/-JjFmQuUPFGw/TiSiAy7okaI/AAAAAAAABJ0/sggZEbEELBk/s640/Publish-SubscribeCommunication.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The example bellow shows how to implement this scenario with using Eneter Messaging Framework.&lt;br /&gt;&amp;nbsp;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;. The online help for developers can be found at &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Publisher&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The publishing application in our example is very simple. It provides just three events that are invoked when the button is clicked.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_DXGM58YRkfQ/TLmGaAmxH0I/AAAAAAAABCg/jX4N2JHnIXw/s1600/PublisherUI.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-ljgT98X-xoc/TiSkyXu2RUI/AAAAAAAABKE/TLkuAPjA9b4/s1600/PublisherUI.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-ljgT98X-xoc/TiSkyXu2RUI/AAAAAAAABKE/TLkuAPjA9b4/s1600/PublisherUI.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;To publish these events the publisher uses the &lt;b&gt;Broker&lt;/b&gt; component. The broker component receives messages via the input channel and forwards them to all subscribed receivers.&lt;br /&gt;In our scenario we want, the broker receives the message when the button is clicked and then forwards it to subscribed receivers.&lt;br /&gt;Therefore we need that our broker can communicate two ways:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;Internally&lt;/i&gt; - to receive internal messages (from the same process) when the 'Notify' button is clicked.&lt;/li&gt;&lt;li&gt; &lt;i&gt;Interprocess&lt;/i&gt; - to register/unregister subscribers and to forward notifications to subscribers.&lt;/li&gt;&lt;/ul&gt;To enable the communication via 2 different channels, we can use the &lt;b&gt;Dispatcher&lt;/b&gt; component.&lt;br /&gt;The dispatcher receives messages and forwards them to all attached receivers. In our case the dispatcher receives messages from two channels (internal messages and interprocess messages) and forwards them to only one receiver - Broker.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_DXGM58YRkfQ/TLrj7UTWqzI/AAAAAAAABDI/mnlthO_xqfk/s1600/Publisher.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-DQ0pMsGlgZo/TiSiyWQIDWI/AAAAAAAABJ4/HVOIlH4ePQw/s1600/Publisher.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="346" src="http://3.bp.blogspot.com/-DQ0pMsGlgZo/TiSiyWQIDWI/AAAAAAAABJ4/HVOIlH4ePQw/s640/Publisher.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The whole implementation is very simple:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.Infrastructure.ConnectionProvider;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.SynchronousMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.Broker;&lt;br /&gt;using Eneter.Messaging.Nodes.Dispatcher;&lt;br /&gt;&lt;br /&gt;namespace Publisher&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        // Notification message 1&lt;br /&gt;        public class NotifyMsg1&lt;br /&gt;        {&lt;br /&gt;            public DateTime CurrentTime { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Notification message 2&lt;br /&gt;        public class NotifyMsg2&lt;br /&gt;        {&lt;br /&gt;            public int Number { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Notification message 3&lt;br /&gt;        public class NotifyMsg3&lt;br /&gt;        {&lt;br /&gt;            public string TextMessage { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create internal messaging system that will be used for the internal communication.&lt;br /&gt;            IMessagingSystemFactory anInternalMessaging = new SynchronousMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            //*******************************************************************************&lt;br /&gt;            // Create communication components that will model our communication scenario&lt;br /&gt;            // -&amp;gt; DuplexBroker: to forward notification messages to subscribers&lt;br /&gt;            // -&amp;gt; DuplexDispatcher: to connect the broker with messaging systems: Tcp, Internal&lt;br /&gt;            // -&amp;gt; BrokerClient: to send notifications from this application to the broker&lt;br /&gt;            //*******************************************************************************&lt;br /&gt;&lt;br /&gt;            // Create broker responsible for forwarding notification messages.&lt;br /&gt;            IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory(new XmlStringSerializer());&lt;br /&gt;            myBroker = aBrokerFactory.CreateBroker();&lt;br /&gt;            &lt;br /&gt;            // Create broker client used to send notification messages from this application.&lt;br /&gt;            myBrokerClient = aBrokerFactory.CreateBrokerClient();&lt;br /&gt;&lt;br /&gt;            // Create Dispatcher that will receive messages from Tcp messaging and also from the internal&lt;br /&gt;            // messaging and send them to the broker.&lt;br /&gt;            // Note: Internal messages will come from myBrokerClient&lt;br /&gt;            //       Tcp messages will come from other applications subscribed for notifications.&lt;br /&gt;            IDuplexDispatcherFactory aDispatcherFactory = new DuplexDispatcherFactory(anInternalMessaging);&lt;br /&gt;            myDispatcher = aDispatcherFactory.CreateDuplexDispatcher();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            //*******************************************************************************&lt;br /&gt;            // "Click" communication components together&lt;br /&gt;            // -&amp;gt; connect the broker with the dispatcher&lt;br /&gt;            // -&amp;gt; connect the dispatcher with the 'broker client'&lt;br /&gt;            // -&amp;gt; connect the dispatcher to Tcp messaging&lt;br /&gt;            //*******************************************************************************&lt;br /&gt;&lt;br /&gt;            // Create helper to create connections for 'internal messaging'.&lt;br /&gt;            // Note: It internally creates input/output channels and connect them to components.&lt;br /&gt;            IConnectionProviderFactory aConnectionProviderFactory = new ConnectionProviderFactory();&lt;br /&gt;            IConnectionProvider aConnectionProvider = aConnectionProviderFactory.CreateConnectionProvider(anInternalMessaging);&lt;br /&gt;&lt;br /&gt;            // Connect the broker to the internal messaging via the duplex input channel.&lt;br /&gt;            aConnectionProvider.Attach(myBroker, "MyBrokerChannelId");&lt;br /&gt;&lt;br /&gt;            // Tell dispatcher to send messages to the broker.&lt;br /&gt;            myDispatcher.AddDuplexOutputChannel("MyBrokerChannelId");&lt;br /&gt;&lt;br /&gt;            // Connect dispatcher with the 'broker client'.&lt;br /&gt;            aConnectionProvider.Connect(myDispatcher, myBrokerClient, "MyInternalDispatcherChannelId");&lt;br /&gt;&lt;br /&gt;            // Create Tcp messaging for the communication with subscribed applications.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Attach Tcp duplex input channel to the dispatcher and start listening.&lt;br /&gt;            IDuplexInputChannel aTcpInputChannel = aMessaging.CreateDuplexInputChannel("127.0.0.1:8091");&lt;br /&gt;            myDispatcher.AttachDuplexInputChannel(aTcpInputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Correctly close listening to Tcp messages.&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myDispatcher.DetachDuplexInputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Send NotifyMsg1&lt;br /&gt;        private void Notify1Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            NotifyMsg1 aMsg = new NotifyMsg1();&lt;br /&gt;            aMsg.CurrentTime = DateTime.Now;&lt;br /&gt;&lt;br /&gt;            object aSerializedMsg = mySerializer.Serialize&amp;lt;NotifyMsg1&amp;gt;(aMsg);&lt;br /&gt;&lt;br /&gt;            myBrokerClient.SendMessage("MyNotifyMsg1", aSerializedMsg);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Send NotifyMsg2&lt;br /&gt;        private void Notify2Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            NotifyMsg2 aMsg = new NotifyMsg2();&lt;br /&gt;            aMsg.Number = 12345;&lt;br /&gt;&lt;br /&gt;            object aSerializedMsg = mySerializer.Serialize&amp;lt;NotifyMsg2&amp;gt;(aMsg);&lt;br /&gt;&lt;br /&gt;            myBrokerClient.SendMessage("MyNotifyMsg2", aSerializedMsg);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Send NotifyMsg3&lt;br /&gt;        private void Notify3Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            NotifyMsg3 aMsg = new NotifyMsg3();&lt;br /&gt;            aMsg.TextMessage = "My notifying text message.";&lt;br /&gt;&lt;br /&gt;            object aSerializedMsg = mySerializer.Serialize&amp;lt;NotifyMsg3&amp;gt;(aMsg);&lt;br /&gt;&lt;br /&gt;            myBrokerClient.SendMessage("MyNotifyMsg3", aSerializedMsg);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // Broker used to forward messages to subscribers.&lt;br /&gt;        private IDuplexBroker myBroker;&lt;br /&gt;&lt;br /&gt;        private IDuplexDispatcher myDispatcher;&lt;br /&gt;&lt;br /&gt;        // Broker client is used to send messages to the broker,&lt;br /&gt;        // that forwards messages to subscribers.&lt;br /&gt;        private IDuplexBrokerClient myBrokerClient;&lt;br /&gt;&lt;br /&gt;        // Serializer used to serialize notification messages.&lt;br /&gt;        // Note: It is possible to use BinarySerializer too.&lt;br /&gt;        //       In that case the messages would have to be declared in a&lt;br /&gt;        //       separate library that would be linked by subscribers too.&lt;br /&gt;        private XmlStringSerializer mySerializer = new XmlStringSerializer();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Subscriber&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The subscribing application in this example is very simple too. It can subscribe and unsubscribe via the button and simply displays the incoming notification messages.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_DXGM58YRkfQ/TLmOLwrFZeI/AAAAAAAABCk/lH1KVkRWDqQ/s1600/SubscriberUI.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-_DnjZz74shU/TiSlu9BlPLI/AAAAAAAABKI/Z0bjruS6X6M/s1600/SubscriberUI.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-_DnjZz74shU/TiSlu9BlPLI/AAAAAAAABKI/Z0bjruS6X6M/s1600/SubscriberUI.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;To subscribe, unsubscribe and receive messages the subscriber uses the BrokerClient component.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_DXGM58YRkfQ/TLrUhGu6fxI/AAAAAAAABDE/fKKTAMxKS5Q/s1600/Subscriber.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-BHDkQRrZye4/TiSizD8cNGI/AAAAAAAABJ8/7--EDDOAvr0/s1600/Subscriber.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="234" src="http://2.bp.blogspot.com/-BHDkQRrZye4/TiSizD8cNGI/AAAAAAAABJ8/7--EDDOAvr0/s640/Subscriber.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The whole implementation is very simple:&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.Broker;&lt;br /&gt;&lt;br /&gt;namespace Subscriber&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        // Notification message 1&lt;br /&gt;        public class NotifyMsg1&lt;br /&gt;        {&lt;br /&gt;            public DateTime CurrentTime { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Notification message 2&lt;br /&gt;        public class NotifyMsg2&lt;br /&gt;        {&lt;br /&gt;            public int Number { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Notification message 3&lt;br /&gt;        public class NotifyMsg3&lt;br /&gt;        {&lt;br /&gt;            public string TextMessage { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create the broker client that will receive notification messages.&lt;br /&gt;            IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory(new XmlStringSerializer());&lt;br /&gt;            myBrokerClient = aBrokerFactory.CreateBrokerClient();&lt;br /&gt;            myBrokerClient.BrokerMessageReceived += OnNotificationMessageReceived;&lt;br /&gt;&lt;br /&gt;            // Create the Tcp messaging for the communication with the publisher.&lt;br /&gt;            // Note: For the interprocess communication you can use: Tcp, NamedPipes and Http.&lt;br /&gt;            IMessagingSystemFactory aMessagingFactory = new TcpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Create duplex output channel for the communication with the publisher.&lt;br /&gt;            // Note: The duplex output channel can send requests and receive responses.&lt;br /&gt;            //       In our case, the broker client will send requests to subscribe/unsubscribe&lt;br /&gt;            //       and receive notifications as response messages.&lt;br /&gt;            IDuplexOutputChannel anOutputChannel = aMessagingFactory.CreateDuplexOutputChannel("127.0.0.1:8091");&lt;br /&gt;&lt;br /&gt;            // Attach the output channel to the broker client&lt;br /&gt;            myBrokerClient.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Correctly close the communication.&lt;br /&gt;        // Note: If the communication is not correctly closed, the thread listening to&lt;br /&gt;        //       response messages will not be closed.&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myBrokerClient.DetachDuplexOutputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Method processing notification messages from the publisher.&lt;br /&gt;        private void OnNotificationMessageReceived(object sender, BrokerMessageReceivedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // The notification event does not come in UI thread.&lt;br /&gt;            // Therefore, if we want to work with UI controls we must execute it in the UI thread.&lt;br /&gt;            InvokeInUIThread(() =&amp;gt;&lt;br /&gt;                {&lt;br /&gt;                    if (e.ReceivingError == null)&lt;br /&gt;                    {&lt;br /&gt;                        if (e.MessageTypeId == "MyNotifyMsg1")&lt;br /&gt;                        {&lt;br /&gt;                            NotifyMsg1 aDeserializedMsg = mySerializer.Deserialize&amp;lt;NotifyMsg1&amp;gt;(e.Message);&lt;br /&gt;                            Received1TextBox.Text = aDeserializedMsg.CurrentTime.ToString();&lt;br /&gt;                        }&lt;br /&gt;                        else if (e.MessageTypeId == "MyNotifyMsg2")&lt;br /&gt;                        {&lt;br /&gt;                            NotifyMsg2 aDeserializedMsg = mySerializer.Deserialize&amp;lt;NotifyMsg2&amp;gt;(e.Message);&lt;br /&gt;                            Received2TextBox.Text = aDeserializedMsg.Number.ToString();&lt;br /&gt;                        }&lt;br /&gt;                        else if (e.MessageTypeId == "MyNotifyMsg3")&lt;br /&gt;                        {&lt;br /&gt;                            NotifyMsg3 aDeserializedMsg = mySerializer.Deserialize&amp;lt;NotifyMsg3&amp;gt;(e.Message);&lt;br /&gt;                            Received3TextBox.Text = aDeserializedMsg.TextMessage;&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;                });&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Subscribe to notification message 1&lt;br /&gt;        private void Subscribe1Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myBrokerClient.Subscribe("MyNotifyMsg1");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Unsubscribe from notification message 1&lt;br /&gt;        private void Unsubscribe1Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Received1TextBox.Text = "";&lt;br /&gt;            myBrokerClient.Unsubscribe("MyNotifyMsg1");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Subscribe to notification message 2&lt;br /&gt;        private void Subscribe2Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myBrokerClient.Subscribe("MyNotifyMsg2");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Unsubscribe from notification message 2&lt;br /&gt;        private void Unsubscribe2Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Received2TextBox.Text = "";&lt;br /&gt;            myBrokerClient.Unsubscribe("MyNotifyMsg2");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Subscribe to notification message 3&lt;br /&gt;        private void Subscribe3Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myBrokerClient.Subscribe("MyNotifyMsg3");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Unsubscribe from notification message 3&lt;br /&gt;        private void Unsubscribe3Btn_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Received3TextBox.Text = "";&lt;br /&gt;            myBrokerClient.Unsubscribe("MyNotifyMsg3");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Helper method to invoke some functionality in UI thread.&lt;br /&gt;        private void InvokeInUIThread(Action uiMethod)&lt;br /&gt;        {&lt;br /&gt;            // If we are not in the UI thread then we must synchronize via the invoke mechanism.&lt;br /&gt;            if (InvokeRequired)&lt;br /&gt;            {&lt;br /&gt;                Invoke(uiMethod);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                uiMethod();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // BrokerClient provides the communication with the broker.&lt;br /&gt;        private IDuplexBrokerClient myBrokerClient;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // Serializer used to sdeerialize notification messages.&lt;br /&gt;        // Note: It is possible to use BinarySerializer too.&lt;br /&gt;        //       In that case the messages would have to be declared in a&lt;br /&gt;        //       separate library that would be linked by publisher too.&lt;br /&gt;        private XmlStringSerializer mySerializer = new XmlStringSerializer();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can execute more subscribers and subscribe/unsubscribe them for desired events. &lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_DXGM58YRkfQ/TLmP1MrsYiI/AAAAAAAABCo/r14nXVMuJ6c/s1600/PublisherSubscribers.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-nqRJqFUcuVM/TiSizjwWbdI/AAAAAAAABKA/G8kbVsg9hww/s1600/PublisherSubscribers.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="426" src="http://1.bp.blogspot.com/-nqRJqFUcuVM/TiSizjwWbdI/AAAAAAAABKA/G8kbVsg9hww/s640/PublisherSubscribers.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I hope you found the article helpful and if you have any questions about Eneter Messaging Framework feel free to ask.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-668820811046965870?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/668820811046965870/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/10/publish-subscribe-communication.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/668820811046965870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/668820811046965870'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/10/publish-subscribe-communication.html' title='Publish-Subscribe Communication'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-JjFmQuUPFGw/TiSiAy7okaI/AAAAAAAABJ0/sggZEbEELBk/s72-c/Publish-SubscribeCommunication.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-5290767135305566913</id><published>2010-10-03T21:12:00.009+02:00</published><updated>2011-07-19T19:50:57.218+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>SSL Communication Between Applications</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt;&lt;br /&gt;The article shows the step by step procedure how to create the self signed certificate and how to configure the SSL connection. The example then implements the Https client server communication with using Eneter.Messaging.Framework.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;SSL (Secure Socket Layer) is a standard security protocol to verify the identity of communicating parts and establish the encrypted communication.&lt;br /&gt;&lt;br /&gt;Here is how the communication works (if only the server is certified):&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The client connects the server and asks for the digital certificate.&lt;/li&gt;&lt;li&gt;The client verifies the received certificate (i.e. if the certificate is issued by a trusted authority, if the domain from the certificate matches with the domain sending the certificate, ...)&lt;/li&gt;&lt;li&gt;The client creates a session key, encrypts it with the public key from the received certificate and sends it to the server.&lt;/li&gt;&lt;li&gt;The server decrypts the session key from the client and uses it to encrypt the content for the client.&lt;/li&gt;&lt;li&gt;The client uses the session key to decrypt the content from the server.&lt;/li&gt;&lt;/ol&gt;&lt;b&gt;Digital Certificate&lt;/b&gt;&lt;br /&gt;The digital certificate is like an Id card. It identifies its owner. And same as in the real world, where ID cards are accepted only if they are issued by trusted authorities (If I create my own driver license, it would not be probably accepted by a policeman.), also digital certificates are accepted if they are issued by trusted authorities.&lt;br /&gt;Therefore, it is important to check if the "Id card" can be accepted - i.e. if the digital certificate was issued (digital signed) by a trusted authority. Typically, for the world wide communication the certificate is issued by a third party mutually trusted authority (e.g. Verisign).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Self Signed Certificate&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;In case, the certificate does not have to be issued (digitally signed) by a trusted third party authority, we can generate our own self signed certificate (e.g. for testing purposes or internal intranet usage, ...).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1. Create Certificate:&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Execute Visual Studio command prompt with &lt;b&gt;Administrator privileges&lt;/b&gt;.&lt;/li&gt;&lt;li style="font-family: inherit;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;makecert -r -n CN="127.0.0.1" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localmachine -sky exchange&lt;/span&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;(Instead of 127.0.0.1 you can use your ip address or the domain name.&lt;br /&gt;Help for 'makecert' can be found &lt;a href="http://msdn.microsoft.com/en-us/library/bfsktky3.aspx"&gt;here&lt;/a&gt;.)&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;&lt;b&gt;2. Configure the certificate to be trusted:&lt;/b&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-GUgw3aIwMFg/TiXCaiOU9HI/AAAAAAAABLI/ZXSeaRUgWdE/s1600/MMC_1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;Execute from the command prompt:&amp;nbsp; &lt;i&gt;mmc&lt;/i&gt;&amp;nbsp;&lt;/li&gt;&lt;li&gt;Choose '&lt;i&gt;Add/Remove Snap-in...&lt;/i&gt;'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-GUgw3aIwMFg/TiXCaiOU9HI/AAAAAAAABLI/ZXSeaRUgWdE/s1600/MMC_1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-GUgw3aIwMFg/TiXCaiOU9HI/AAAAAAAABLI/ZXSeaRUgWdE/s1600/MMC_1.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_DXGM58YRkfQ/TKeq7tbiG1I/AAAAAAAABBY/4_WfYy3M9SQ/s1600/MMC_1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Doubleclick '&lt;i&gt;Certificates&lt;/i&gt;'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-TvBfEaFdK0o/TiXCtzJtRqI/AAAAAAAABLM/dzfghVB4nxQ/s1600/MMC_2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-TvBfEaFdK0o/TiXCtzJtRqI/AAAAAAAABLM/dzfghVB4nxQ/s1600/MMC_2.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_DXGM58YRkfQ/TKesKGVXy5I/AAAAAAAABBc/RMLBZLQrG1c/s1600/MMC_2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Choose '&lt;i&gt;Computer account&lt;/i&gt;'&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-laTAI8smTWs/TiXC4XZKuXI/AAAAAAAABLQ/rfEw0ra37mA/s1600/MMC_3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-laTAI8smTWs/TiXC4XZKuXI/AAAAAAAABLQ/rfEw0ra37mA/s1600/MMC_3.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_DXGM58YRkfQ/TKes2y9ddQI/AAAAAAAABBg/zNqcfft51vE/s1600/MMC_3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/--6g-n6akMoM/TiXDBMWiJII/AAAAAAAABLU/PImaT7WYSZY/s1600/MMC_4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/--6g-n6akMoM/TiXDBMWiJII/AAAAAAAABLU/PImaT7WYSZY/s1600/MMC_4.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_DXGM58YRkfQ/TKes3vmFrPI/AAAAAAAABBk/xvQIX7cJXTU/s1600/MMC_4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The new certificate should be found under '&lt;i&gt;Personal Certificates&lt;/i&gt;'.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/--8HwIXTCEkk/TiXDM-RS5mI/AAAAAAAABLY/ciI6chspuwU/s1600/MMC_5.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/--8HwIXTCEkk/TiXDM-RS5mI/AAAAAAAABLY/ciI6chspuwU/s1600/MMC_5.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_DXGM58YRkfQ/TKipbF2qGLI/AAAAAAAABCE/nz82qcu92sA/s1600/MMC_5.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The new certificate is among personal certificates, but it is not trusted. When we double-click the certificate,&amp;nbsp; the following message will be there:&amp;nbsp; "&lt;b&gt;&lt;i style="color: #cc0000;"&gt;This CA Root certificate is not trusted. To enable trust, install this certificate in the Trusted Root Certification Authorities store.&lt;/i&gt;&lt;/b&gt;"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-pzrIwfYAEgo/TiXDWadaJ2I/AAAAAAAABLc/Ec6N4fXDpHg/s1600/MMC_6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-pzrIwfYAEgo/TiXDWadaJ2I/AAAAAAAABLc/Ec6N4fXDpHg/s1600/MMC_6.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_DXGM58YRkfQ/TKipmA2JzvI/AAAAAAAABCI/cLmskNVHgtU/s1600/MMC_6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;To resolve this issue, copy and paste the new certificate into '&lt;i&gt;Trusted Root Certification Authorities&lt;/i&gt;'.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-w6Ivj5JFvVE/TiXDgpj2icI/AAAAAAAABLg/7GshdDoXLzY/s1600/MMC_7.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-w6Ivj5JFvVE/TiXDgpj2icI/AAAAAAAABLg/7GshdDoXLzY/s1600/MMC_7.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_DXGM58YRkfQ/TKiry9Bpl8I/AAAAAAAABCM/cltXjVgQRYc/s1600/MMC_7.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-WKsw5w-pwl4/TiXDrRXgR3I/AAAAAAAABLk/X-X9UdjYKD4/s1600/MMC_8.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-WKsw5w-pwl4/TiXDrRXgR3I/AAAAAAAABLk/X-X9UdjYKD4/s1600/MMC_8.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_DXGM58YRkfQ/TKir0NbcBfI/AAAAAAAABCQ/Z936PQOhzQE/s1600/MMC_8.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The certificate is trusted now.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-AbAesuI9ri4/TiXDzK0beEI/AAAAAAAABLo/oVJ3BfDlB34/s1600/MMC_9.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-AbAesuI9ri4/TiXDzK0beEI/AAAAAAAABLo/oVJ3BfDlB34/s1600/MMC_9.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_DXGM58YRkfQ/TKisy3AIDcI/AAAAAAAABCU/tfYT-MIKOjw/s1600/MMC_9.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;b&gt;4. Configure the certificate for a desired ip address and port:&lt;/b&gt;&lt;br /&gt;In our case, we configure the certificate for all ip addresses and the port 7788.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Copy the '&lt;i&gt;Thumbprint&lt;/i&gt;' from the certificate, paste it to the notepad and remove spaces between numbers - this thumbprint data will be used in the next step.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-z-zAZCH81x4/TiXD6AJGDFI/AAAAAAAABLs/FYVRZrTV4pM/s1600/MMC_10.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-z-zAZCH81x4/TiXD6AJGDFI/AAAAAAAABLs/FYVRZrTV4pM/s1600/MMC_10.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_DXGM58YRkfQ/TKi8AoFi-zI/AAAAAAAABCc/CKCizyVBkLo/s1600/MMC_10.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Configure the ip address and the port for the certificate. Use your own thumbprint data in the command.&lt;br /&gt;&lt;br /&gt;The command for Windows Vista:&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;netsh http add sslcert ipport=0.0.0.0:7788 certhash=&lt;span style="background-color: #cfe2f3;"&gt;a357e3f991763516a4119153e137df24f88f18ac&lt;/span&gt; appid={00000000-0000-0000-0000-000000000000}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The command for Windows XP:&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;httpcfg set ssl /i 0.0.0.0:7788 /h &lt;span style="background-color: #d0e0e3;"&gt;a357e3f991763516a4119153e137df24f88f18ac&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;(Note: You need to download &lt;i&gt;HttpCfg.exe&lt;/i&gt; from &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyId=49AE8576-9BB9-4126-9761-BA8011FABF38&amp;amp;displaylang=en"&gt;Microsoft&lt;/a&gt;) &lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Https Client Server Communication&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The self signed certificate is now ready, and we can use it for the client server communication.&lt;br /&gt;The following example implements the simple client-server with using Eneter.Messaging.Framework.&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;http://www.eneter.net/&lt;/a&gt;. The online help for developers can be found on &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Sever application&lt;/span&gt;&lt;br /&gt;The server is a simple application listening to request to count two numbers.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Important: &lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The server domain must be same as the certificate name. It is 127.0.0.1 in our case. Otherwise the certificate check will fail on the client side and the connection will not be established.&lt;/li&gt;&lt;li&gt;The server must be executes with sufficient user rights. Execute it as &lt;b&gt;Administrator&lt;/b&gt; for debugging purposes. Otherwise the server will fail to start.&lt;/li&gt;&lt;/ul&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.HttpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;namespace HttpService&lt;br /&gt;{&lt;br /&gt;    // Message requesting counting of two numbers.&lt;br /&gt;    public class MyRequestMessage&lt;br /&gt;    {&lt;br /&gt;        public int Number1 { get; set; }&lt;br /&gt;        public int Number2 { get; set; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    // Message returning the counting result.&lt;br /&gt;    public class MyResponseMessage&lt;br /&gt;    {&lt;br /&gt;        public int Result { get; set; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Create messaging using Https.&lt;br /&gt;            IMessagingSystemFactory aMessagingFactory = new HttpMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel anInputChannel = aMessagingFactory.CreateDuplexInputChannel("https://127.0.0.1:7788");&lt;br /&gt;&lt;br /&gt;            // Create the message receiver that receives MyRequestMessage and resonses MyResponseMessage.&lt;br /&gt;            IDuplexTypedMessagesFactory aTypedMessages = new DuplexTypedMessagesFactory(new XmlStringSerializer());&lt;br /&gt;            IDuplexTypedMessageReceiver&amp;lt;MyResponseMessage, MyRequestMessage&amp;gt; aMessageReceiver = aTypedMessages.CreateDuplexTypedMessageReceiver&amp;lt;MyResponseMessage, MyRequestMessage&amp;gt;();&lt;br /&gt;            &lt;br /&gt;            // Subscribe to process incoming messages.&lt;br /&gt;            aMessageReceiver.MessageReceived += MessageReceived;&lt;br /&gt;&lt;br /&gt;            // Start listening for messages.&lt;br /&gt;            Console.WriteLine("The server is listening.");&lt;br /&gt;            aMessageReceiver.AttachDuplexInputChannel(anInputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Processes incoming messages.&lt;br /&gt;        static void MessageReceived(object sender, TypedRequestReceivedEventArgs&amp;lt;MyRequestMessage&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                // Count incoming numbers.&lt;br /&gt;                MyResponseMessage aResponse = new MyResponseMessage();&lt;br /&gt;                aResponse.Result = e.RequestMessage.Number1 + e.RequestMessage.Number2;&lt;br /&gt;&lt;br /&gt;                Console.WriteLine("Result = " + aResponse.Result.ToString());&lt;br /&gt;&lt;br /&gt;                // Resonse the result back to the sender.&lt;br /&gt;                IDuplexTypedMessageReceiver&amp;lt;MyResponseMessage, MyRequestMessage&amp;gt; aReceiver = (IDuplexTypedMessageReceiver&amp;lt;MyResponseMessage, MyRequestMessage&amp;gt;)sender;&lt;br /&gt;                aReceiver.SendResponseMessage(e.ResponseReceiverId, aResponse);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Client application&lt;/span&gt;&lt;br /&gt;The client is a simple application sending the request to the server to count two numbers.&lt;br /&gt;The whole implementation is here:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.HttpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;&lt;br /&gt;namespace HttpClient&lt;br /&gt;{&lt;br /&gt;    // Message requesting counting of two numbers.&lt;br /&gt;    public class MyRequestMessage&lt;br /&gt;    {&lt;br /&gt;        public int Number1 { get; set; }&lt;br /&gt;        public int Number2 { get; set; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    // Message returning the counting result.&lt;br /&gt;    public class MyResponseMessage&lt;br /&gt;    {&lt;br /&gt;        public int Result { get; set; }&lt;br /&gt;    };&lt;br /&gt;&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Create messaging using Https.&lt;br /&gt;            IMessagingSystemFactory aMessagingFactory = new HttpMessagingSystemFactory();&lt;br /&gt;            IDuplexOutputChannel anOutputChannel = aMessagingFactory.CreateDuplexOutputChannel("https://127.0.0.1:7788");&lt;br /&gt;&lt;br /&gt;            // Create the message sender that sends MyRequestMessage and receive resonses MyResponseMessage.&lt;br /&gt;            IDuplexTypedMessagesFactory aTypedMessages = new DuplexTypedMessagesFactory(new XmlStringSerializer());&lt;br /&gt;            IDuplexTypedMessageSender&amp;lt;MyResponseMessage, MyRequestMessage&amp;gt; aMessageSender = aTypedMessages.CreateDuplexTypedMessageSender&amp;lt;MyResponseMessage, MyRequestMessage&amp;gt;();&lt;br /&gt;            &lt;br /&gt;            // Subscribe to handle responses.&lt;br /&gt;            aMessageSender.ResponseReceived += ResponseReceived;&lt;br /&gt;            &lt;br /&gt;            // Attach the the Https channel to send request messages and receive response messages.&lt;br /&gt;            aMessageSender.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;&lt;br /&gt;            // Very simple loop getting numbers from the user and sending requests to the server.&lt;br /&gt;            while (true)&lt;br /&gt;            {&lt;br /&gt;                MyRequestMessage aRequest = new MyRequestMessage();&lt;br /&gt;&lt;br /&gt;                Console.Write("Number 1: ");&lt;br /&gt;                aRequest.Number1 = int.Parse(Console.ReadLine());&lt;br /&gt;&lt;br /&gt;                Console.Write("Number 2: ");&lt;br /&gt;                aRequest.Number2 = int.Parse(Console.ReadLine());&lt;br /&gt;&lt;br /&gt;                // Send the request to count inserted numbers.&lt;br /&gt;                aMessageSender.SendRequestMessage(aRequest);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Handles received response messages.&lt;br /&gt;        static void ResponseReceived(object sender, TypedResponseReceivedEventArgs&amp;lt;MyResponseMessage&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine("Result: " + e.ResponseMessage.Result.ToString());&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;I hope you found the article useful. If you would like to have more information about Eneter.Messaging.Framework, you can find it on &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-5290767135305566913?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/5290767135305566913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/10/ssl-communication-between-applications.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/5290767135305566913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/5290767135305566913'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/10/ssl-communication-between-applications.html' title='SSL Communication Between Applications'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-GUgw3aIwMFg/TiXCaiOU9HI/AAAAAAAABLI/ZXSeaRUgWdE/s72-c/MMC_1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-3522637418983111207</id><published>2010-08-15T21:19:00.007+02:00</published><updated>2011-07-19T19:40:22.889+02:00</updated><title type='text'>Error Handling and Diagnostic in Eneter.Messaging.Framework</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; The article describes the error handling behavior of Eneter.Messaging.Framework and shows how to use Debug View for the diagnostic.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Introduction for newcomers&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;If you are new, then Eneter.Messaging.Framework is a middleware that allows to implement the communication between applications based on messages. The framework supports NamedPipes, Tcp, Http and also Silverlight Messaging.&lt;br /&gt;For more technical details you can refer to my previous articles or you can visit&lt;br /&gt;&lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;.&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Error handling behavior&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The error handling in Eneter.Messaging.Framework is based on 4 main scenarios:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1. The error occurs in the framework when the user invokes some API method.&lt;/b&gt;&lt;br /&gt;This scenario occurs when the user calls the framework API and the call fails.&lt;br /&gt;E.g. the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;SendMessage()&lt;/span&gt; method is called but the output channel is not attached. Or when you create the channel and the channel id is not the valid Uri address (in case of Named Pipe, Tcp or Http). &lt;br /&gt;&lt;br /&gt;In this case the framework logs the error to the debug port and throws an exception.&lt;br /&gt;(&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: small;"&gt;ArgumentException, ArgumentNullException, InvalidOperationException&lt;/span&gt; or a communication technology specific exception)&lt;br /&gt;The exception can be caught in the user code and processed.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2. The error occurs in the user code when is invoked from the framework as a callback.&lt;/b&gt;&lt;br /&gt;This scenario typically occurs when the framework calls an event handler (or a callback) provided by the user and this handler throws an exception.&lt;br /&gt;E.g. the framework calls the user code subscribed to the event &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;MessageReceived&lt;/span&gt; and the user code throws some exception.&lt;br /&gt;&lt;br /&gt;In this case the framework catches all exceptions and log them to the debug port.&lt;br /&gt;(In spite of the fact, the framework handles these exceptions, it is recomended that exceptions from event handlers and callbacks are not propagated to the framework. Better, the user code should catch them.)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3. The error occurs in the framework code during processing a received message.&lt;/b&gt;&lt;br /&gt;This scenario occurs when the framework receives a message from a sender and detects a problem during processing of the message.&lt;br /&gt;E.g. the deserialization of the received message failed.&lt;br /&gt;&lt;br /&gt;In this case the framework logs the error to the debug port and notifies the error to the user code in the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: small;"&gt;MessageReceived&lt;/span&gt; event. The event has the property&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;span style="font-size: small;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: #45818e;"&gt;Exception&lt;/span&gt; ReceivingError {get;}&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;The user code should evaluate this property when processes a received message.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4. The error occurs in a framework component in runtime.&lt;/b&gt;&lt;br /&gt;This scenario normally should not occur. But if the framework detects some error that cannot be reported to the user code via exception or event, the framework logs the error to the debug port, from where it can be read by a programmer.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Diagnostic&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;As described above, whenever the framework detects an error it uses the debug port to announce the issue. Except errors, the framework also recognizes potential problems and announces them to the debug port as warning messages.&lt;br /&gt;Therefore, to diagnose the communication, you can use a debug port viewer. E.g. you can download one from Microsoft.&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx"&gt;http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To recognize messages in the debug port more effectively, you can setup the filter and colors. E.g. errors can be red and warnings yellow. The framework labels errors as ' E:' and warnings as ' W:'.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-OYljyaxhunM/TiXBRLrQpWI/AAAAAAAABK8/sNxvxPVIa5Q/s1600/DebugViewFilterSetting.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-OYljyaxhunM/TiXBRLrQpWI/AAAAAAAABK8/sNxvxPVIa5Q/s1600/DebugViewFilterSetting.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;And here is the example of the output for Eneter.Messaging.Framework. &lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_DXGM58YRkfQ/TGg-aetZbpI/AAAAAAAABBE/o_oGXv2vhtI/s1600/DebugViewExample.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-UhC8QoKrbh4/TiXBcIYxLBI/AAAAAAAABLA/_xaZwSt9PFc/s1600/DebugViewExample.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="160" src="http://4.bp.blogspot.com/-UhC8QoKrbh4/TiXBcIYxLBI/AAAAAAAABLA/_xaZwSt9PFc/s640/DebugViewExample.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I hope, you enjoyed the article.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-3522637418983111207?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/3522637418983111207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/08/error-handling-and-diagnostic-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/3522637418983111207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/3522637418983111207'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/08/error-handling-and-diagnostic-in.html' title='Error Handling and Diagnostic in Eneter.Messaging.Framework'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-OYljyaxhunM/TiXBRLrQpWI/AAAAAAAABK8/sNxvxPVIa5Q/s72-c/DebugViewFilterSetting.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-945763805423790719</id><published>2010-08-03T22:21:00.007+02:00</published><updated>2011-07-19T19:36:44.441+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>How to Implement Service Receiving Requests via Messages</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; The example in the article implements the service application Calculator. This service application listens to request messages and calculate numbers (summation, subtraction, multiplication and dividing). The result is then sent back to the requesting client as the response message.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To use the implementation bellow you must include the &lt;i&gt;Eneter.Messaging.Framework.dll&lt;/i&gt; library into your project. (Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;. The online help for developers can be found &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Service application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The Calculator service provides the following functionality: summation, subtraction, multiplication and dividing. Therefore the service recognizes four types of request messages. Every request message will take two numbers as the input for the calculation.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;// Input data for calculator requests&lt;br /&gt;public class CalculatorInputData&lt;br /&gt;{&lt;br /&gt;    public double Number1 { get; set; }&lt;br /&gt;    public double Number2 { get; set; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;When the service calculates numbers it sends back the response message with the result.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;// Output result from the calculator&lt;br /&gt;public class CalculatorOutputData&lt;br /&gt;{&lt;br /&gt;    public double Result { get; set; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;We also want that the service listens to request messages on one address (one input channel). (It would not be effective if every type of request message would have its own address.)&lt;br /&gt;To recognize multiple message types on one address we use the Channel Unwrapper component from Eneter.Messaging.Framework.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-fnmepCenfJs/TiXAHrkCQII/AAAAAAAABKw/0F7TePM5rzs/s1600/DuplexChannelUnwrapper.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="304" src="http://1.bp.blogspot.com/-fnmepCenfJs/TiXAHrkCQII/AAAAAAAABKw/0F7TePM5rzs/s640/DuplexChannelUnwrapper.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The Channel Unwrapper component receives messages on one input channel, "unwraps" them and forwards to correct receivers.&lt;br /&gt;In our case the Channel Unwrapper recognizes if the incoming message is summation, subtraction, multiplication or dividing. Then it forwards the message to the correct receiver handling the requested type of calculation.&lt;br /&gt;&lt;br /&gt;The code implementing the behavior above is very simple with Eneter.Messaging.Framework.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;&lt;br /&gt;namespace ServerCalculator2&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            Calculator aCalculator = new Calculator();&lt;br /&gt;            Console.WriteLine("Calculator service started.");&lt;br /&gt;            aCalculator.StartCalculatorService();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.Infrastructure.ConnectionProvider;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.ThreadPoolMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.ChannelWrapper;&lt;br /&gt;&lt;br /&gt;namespace ServerCalculator2&lt;br /&gt;{&lt;br /&gt;    // Input data for calculator requests&lt;br /&gt;    public class CalculatorInputData&lt;br /&gt;    {&lt;br /&gt;        public double Number1 { get; set; }&lt;br /&gt;        public double Number2 { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // Output result from the calculator&lt;br /&gt;    public class CalculatorOutputData&lt;br /&gt;    {&lt;br /&gt;        public double Result { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    internal class Calculator&lt;br /&gt;    {&lt;br /&gt;        public Calculator()&lt;br /&gt;        {&lt;br /&gt;            // We want that requests do not block each other. So every request will be processed in its own thread.&lt;br /&gt;            IMessagingSystemFactory anInternalMessaging = new ThreadPoolMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // We want to use Xml for serialization/deserialization.&lt;br /&gt;            // Note: Alternative you can use: BinarySerializer&lt;br /&gt;            ISerializer aSerializer = new XmlStringSerializer();&lt;br /&gt;&lt;br /&gt;            // All messages are received via one channel. So we must provide "unwrapper" forwarding incoming messages&lt;br /&gt;            // to correct receivers.&lt;br /&gt;            IChannelWrapperFactory aChannelWrapperFactory = new ChannelWrapperFactory(aSerializer);&lt;br /&gt;            myDuplexChannelUnwrapper = aChannelWrapperFactory.CreateDuplexChannelUnwrapper(anInternalMessaging);&lt;br /&gt;&lt;br /&gt;            // To connect receivers and the unwrapper with duplex channels we can use the following helper class.&lt;br /&gt;            IConnectionProviderFactory aConnectionProviderFactory = new ConnectionProviderFactory();&lt;br /&gt;            IConnectionProvider aConnectionProvider = aConnectionProviderFactory.CreateConnectionProvider(anInternalMessaging);&lt;br /&gt;&lt;br /&gt;            // Factory to create message receivers.&lt;br /&gt;            // Received messages will be deserialized from Xml.&lt;br /&gt;            IDuplexTypedMessagesFactory aMessageReceiverFactory = new DuplexTypedMessagesFactory(aSerializer);&lt;br /&gt;            &lt;br /&gt;            // Create receiver to sum two numbers.&lt;br /&gt;            mySumReceiver = aMessageReceiverFactory.CreateDuplexTypedMessageReceiver&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt;();&lt;br /&gt;            mySumReceiver.MessageReceived += SumCmd; // attach method handling the request&lt;br /&gt;            aConnectionProvider.Attach(mySumReceiver, "Sum"); // attach the input channel to get messages from unwrapper&lt;br /&gt;&lt;br /&gt;            // Receiver to subtract two numbers.&lt;br /&gt;            mySubtractReceiver = aMessageReceiverFactory.CreateDuplexTypedMessageReceiver&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt;();&lt;br /&gt;            mySubtractReceiver.MessageReceived += SubCmd; // attach method handling the request&lt;br /&gt;            aConnectionProvider.Attach(mySubtractReceiver, "Sub"); // attach the input channel to get messages from unwrapper&lt;br /&gt;&lt;br /&gt;            // Receiver for multiply two numbers.&lt;br /&gt;            myMultiplyReceiver = aMessageReceiverFactory.CreateDuplexTypedMessageReceiver&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt;();&lt;br /&gt;            myMultiplyReceiver.MessageReceived += MulCmd; // attach method handling the request&lt;br /&gt;            aConnectionProvider.Attach(myMultiplyReceiver, "Mul"); // attach the input channel to get messages from unwrapper&lt;br /&gt;&lt;br /&gt;            // Receiver for divide two numbers.&lt;br /&gt;            myDivideReceiver = aMessageReceiverFactory.CreateDuplexTypedMessageReceiver&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt;();&lt;br /&gt;            myDivideReceiver.MessageReceived += DivCmd; // attach method handling the request&lt;br /&gt;            aConnectionProvider.Attach(myDivideReceiver, "Div"); // attach the input channel to get messages from unwrapper&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        public void StartCalculatorService()&lt;br /&gt;        {&lt;br /&gt;            // We will use Tcp for the communication.&lt;br /&gt;            IMessagingSystemFactory aServiceMessagingSystem = new TcpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Create input channel for the calculator receiving messages via Tcp.&lt;br /&gt;            IDuplexInputChannel aGlobalInputChannel = aServiceMessagingSystem.CreateDuplexInputChannel("127.0.0.1:8091");&lt;br /&gt;&lt;br /&gt;            // Attach the input channel to the unwrapper and start to listening.&lt;br /&gt;            myDuplexChannelUnwrapper.AttachDuplexInputChannel(aGlobalInputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // It is called when a request to sum two numbers was received.&lt;br /&gt;        private void SumCmd(object sender, TypedRequestReceivedEventArgs&amp;lt;CalculatorInputData&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // Get input data.&lt;br /&gt;            CalculatorInputData anInputData = e.RequestMessage;&lt;br /&gt;&lt;br /&gt;            // Calculate output result.&lt;br /&gt;            CalculatorOutputData aReturn = new CalculatorOutputData();&lt;br /&gt;            aReturn.Result = anInputData.Number1 + anInputData.Number2;&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("{0} + {1} = {2}", anInputData.Number1, anInputData.Number2, aReturn.Result);&lt;br /&gt;&lt;br /&gt;            // Response result to the client.&lt;br /&gt;            mySumReceiver.SendResponseMessage(e.ResponseReceiverId, aReturn);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // It is called when a request to subtract two numbers was received.&lt;br /&gt;        private void SubCmd(object sender, TypedRequestReceivedEventArgs&amp;lt;CalculatorInputData&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // Get input data.&lt;br /&gt;            CalculatorInputData anInputData = e.RequestMessage;&lt;br /&gt;&lt;br /&gt;            // Calculate output result.&lt;br /&gt;            CalculatorOutputData aReturn = new CalculatorOutputData();&lt;br /&gt;            aReturn.Result = anInputData.Number1 - anInputData.Number2;&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("{0} - {1} = {2}", anInputData.Number1, anInputData.Number2, aReturn.Result);&lt;br /&gt;&lt;br /&gt;            // Response result to the client.&lt;br /&gt;            mySubtractReceiver.SendResponseMessage(e.ResponseReceiverId, aReturn);&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;&lt;br /&gt;        // It is called when a request to multiply two numbers was received.&lt;br /&gt;        private void MulCmd(object sender, TypedRequestReceivedEventArgs&amp;lt;CalculatorInputData&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // Get input data.&lt;br /&gt;            CalculatorInputData anInputData = e.RequestMessage;&lt;br /&gt;&lt;br /&gt;            // Calculate output result.&lt;br /&gt;            CalculatorOutputData aReturn = new CalculatorOutputData();&lt;br /&gt;            aReturn.Result = anInputData.Number1 * anInputData.Number2;&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("{0} x {1} = {2}", anInputData.Number1, anInputData.Number2, aReturn.Result);&lt;br /&gt;&lt;br /&gt;            // Response result to the client.&lt;br /&gt;            myMultiplyReceiver.SendResponseMessage(e.ResponseReceiverId, aReturn);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // It is called when a request to divide two numbers was received.&lt;br /&gt;        private void DivCmd(object sender, TypedRequestReceivedEventArgs&amp;lt;CalculatorInputData&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // Get input data.&lt;br /&gt;            CalculatorInputData anInputData = e.RequestMessage;&lt;br /&gt;&lt;br /&gt;            // Calculate output result.&lt;br /&gt;            CalculatorOutputData aReturn = new CalculatorOutputData();&lt;br /&gt;            aReturn.Result = anInputData.Number1 / anInputData.Number2;&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("{0} / {1} = {2}", anInputData.Number1, anInputData.Number2, aReturn.Result);&lt;br /&gt;&lt;br /&gt;            // Response result to the client.&lt;br /&gt;            myDivideReceiver.SendResponseMessage(e.ResponseReceiverId, aReturn);&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // Block is the helper to create the infrastructure with less code.&lt;br /&gt;        private IDuplexChannelUnwrapper myDuplexChannelUnwrapper;&lt;br /&gt;&lt;br /&gt;        private IDuplexTypedMessageReceiver&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt; mySumReceiver;&lt;br /&gt;        private IDuplexTypedMessageReceiver&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt; mySubtractReceiver;&lt;br /&gt;        private IDuplexTypedMessageReceiver&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt; myMultiplyReceiver;&lt;br /&gt;        private IDuplexTypedMessageReceiver&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt; myDivideReceiver;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Client Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The client application implements a simple UI taking numbers and invoking requests for the calculation.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-PNf9KRUuQOA/TiXATRUPqkI/AAAAAAAABK0/cGQiqfickiI/s1600/CalculatorUI.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-PNf9KRUuQOA/TiXATRUPqkI/AAAAAAAABK0/cGQiqfickiI/s1600/CalculatorUI.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_DXGM58YRkfQ/TFhz4oPA8YI/AAAAAAAABAQ/EbaNWXuEwQA/s1600/CalculatorUI.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;To send multiple message types to the Calculator service via one output channel (because the service receives messages via one input channel (address)), the client must use the Channel Wrapper component. The Channel Wrapper component wrapps outgoing request messages so that they can be unwrapped by the service when they are received.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-D5M9JuL2NfQ/TiXAdx8kW0I/AAAAAAAABK4/2OKi8dH143M/s1600/DuplexChannelWrapper.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="308" src="http://1.bp.blogspot.com/-D5M9JuL2NfQ/TiXAdx8kW0I/AAAAAAAABK4/2OKi8dH143M/s640/DuplexChannelWrapper.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_DXGM58YRkfQ/TFh0O-Kbs0I/AAAAAAAABAY/3Tp9udi_SXE/s1600/DuplexChannelWrapper.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The code implementing the client behavior is very simple too. &lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.Infrastructure.ConnectionProvider;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.ThreadMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.ChannelWrapper;&lt;br /&gt;&lt;br /&gt;namespace CalculatorClient2&lt;br /&gt;{&lt;br /&gt;    // Input data for calculator requests&lt;br /&gt;    public class CalculatorInputData&lt;br /&gt;    {&lt;br /&gt;        public double Number1 { get; set; }&lt;br /&gt;        public double Number2 { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // Output result from the calculator&lt;br /&gt;    public class CalculatorOutputData&lt;br /&gt;    {&lt;br /&gt;        public double Result { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // We want that sending of requests will be not blocking. Therefore we will choose&lt;br /&gt;            // ThreadMessaging with the queue.&lt;br /&gt;            IMessagingSystemFactory anInternalMessaging = new ThreadMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // We want to use Xml for serialization/deserialization.&lt;br /&gt;            // Note: Alternative you can use: BinarySerializer&lt;br /&gt;            ISerializer aSerializer = new XmlStringSerializer();&lt;br /&gt;&lt;br /&gt;            // The service receives messages via one channel (i.e. it listens on one address).&lt;br /&gt;            // The incoming messages are unwrapped on the server side.&lt;br /&gt;            // Therefore the client must use wrapper to send messages via one channel.&lt;br /&gt;            IChannelWrapperFactory aChannelWrapperFactory = new ChannelWrapperFactory(aSerializer);&lt;br /&gt;            myDuplexChannelWrapper = aChannelWrapperFactory.CreateDuplexChannelWrapper();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            // To connect message senders and the wrapper with duplex channels we can use the following helper class.&lt;br /&gt;            IConnectionProviderFactory aConnectionProviderFactory = new ConnectionProviderFactory();&lt;br /&gt;            IConnectionProvider aConnectionProvider = aConnectionProviderFactory.CreateConnectionProvider(anInternalMessaging);&lt;br /&gt;&lt;br /&gt;            &lt;br /&gt;            // Factory to create message senders.&lt;br /&gt;            // Sent messages will be serialized in Xml.&lt;br /&gt;            IDuplexTypedMessagesFactory aCommandsFactory = new DuplexTypedMessagesFactory(aSerializer);&lt;br /&gt;&lt;br /&gt;            // Sender to sum two numbers.&lt;br /&gt;            mySumSender = aCommandsFactory.CreateDuplexTypedMessageSender&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt;();&lt;br /&gt;            mySumSender.ResponseReceived += OnResultResponse;&lt;br /&gt;            aConnectionProvider.Connect(myDuplexChannelWrapper, mySumSender, "Sum");&lt;br /&gt;&lt;br /&gt;            // Sender to subtract two numbers.&lt;br /&gt;            mySubSender = aCommandsFactory.CreateDuplexTypedMessageSender&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt;();&lt;br /&gt;            mySubSender.ResponseReceived += OnResultResponse;&lt;br /&gt;            aConnectionProvider.Connect(myDuplexChannelWrapper, mySubSender, "Sub");&lt;br /&gt;&lt;br /&gt;            // Sender to multiply two numbers.&lt;br /&gt;            myMulSender = aCommandsFactory.CreateDuplexTypedMessageSender&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt;();&lt;br /&gt;            myMulSender.ResponseReceived += OnResultResponse;&lt;br /&gt;            aConnectionProvider.Connect(myDuplexChannelWrapper, myMulSender, "Mul");&lt;br /&gt;&lt;br /&gt;            // Sender to divide two numbers.&lt;br /&gt;            myDivSender = aCommandsFactory.CreateDuplexTypedMessageSender&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt;();&lt;br /&gt;            myDivSender.ResponseReceived += OnResultResponse;&lt;br /&gt;            aConnectionProvider.Connect(myDuplexChannelWrapper, myDivSender, "Div");&lt;br /&gt;&lt;br /&gt;            // We use Tcp for the communication.&lt;br /&gt;            IMessagingSystemFactory aTcpMessagingSystem = new TcpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Create output channel to send requests to the service.&lt;br /&gt;            IDuplexOutputChannel anOutputChannel = aTcpMessagingSystem.CreateDuplexOutputChannel("127.0.0.1:8091");&lt;br /&gt;&lt;br /&gt;            // Attach the output channel to the wrapper - so that we are able to send messages.&lt;br /&gt;            // Note: The service has the coresponding unwrapper.&lt;br /&gt;            myDuplexChannelWrapper.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Stop listening by detaching the input channel.&lt;br /&gt;            myDuplexChannelWrapper.DetachDuplexOutputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        private void OnResultResponse(object sender, TypedResponseReceivedEventArgs&amp;lt;CalculatorOutputData&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // If everything is ok then display the result.&lt;br /&gt;            if (e.ReceivingError == null)&lt;br /&gt;            {&lt;br /&gt;                // The response does not come in main UI thread.&lt;br /&gt;                // Therefore we must transfer it to the main UI thread.&lt;br /&gt;                InvokeInUIThread(() =&amp;gt; ResultLabel.Text = e.ResponseMessage.Result.ToString() );&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void CalculateButton_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Prepare input data for the calculator.&lt;br /&gt;            CalculatorInputData anInputForCalculator = new CalculatorInputData();&lt;br /&gt;            anInputForCalculator.Number1 = double.Parse(Number1TextBox.Text);&lt;br /&gt;            anInputForCalculator.Number2 = double.Parse(Number2TextBox.Text);&lt;br /&gt;&lt;br /&gt;            // Invoke request to sum.&lt;br /&gt;            mySumSender.SendRequestMessage(anInputForCalculator);&lt;br /&gt;        }&lt;br /&gt;         &lt;br /&gt;        private void SubtractButton_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Prepare input data for the calculator.&lt;br /&gt;            CalculatorInputData anInputForCalculator = new CalculatorInputData();&lt;br /&gt;            anInputForCalculator.Number1 = double.Parse(Number1TextBox.Text);&lt;br /&gt;            anInputForCalculator.Number2 = double.Parse(Number2TextBox.Text);&lt;br /&gt;&lt;br /&gt;            // Invoke request to substract.&lt;br /&gt;            mySubSender.SendRequestMessage(anInputForCalculator);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void MultiplyButton_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Prepare input data for the calculator.&lt;br /&gt;            CalculatorInputData anInputForCalculator = new CalculatorInputData();&lt;br /&gt;            anInputForCalculator.Number1 = double.Parse(Number1TextBox.Text);&lt;br /&gt;            anInputForCalculator.Number2 = double.Parse(Number2TextBox.Text);&lt;br /&gt;&lt;br /&gt;            // Invoke request to multiply.&lt;br /&gt;            myMulSender.SendRequestMessage(anInputForCalculator);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void DivideButton_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Prepare input data for the calculator.&lt;br /&gt;            CalculatorInputData anInputForCalculator = new CalculatorInputData();&lt;br /&gt;            anInputForCalculator.Number1 = double.Parse(Number1TextBox.Text);&lt;br /&gt;            anInputForCalculator.Number2 = double.Parse(Number2TextBox.Text);&lt;br /&gt;&lt;br /&gt;            // Invoke request to divide.&lt;br /&gt;            myDivSender.SendRequestMessage(anInputForCalculator);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Helper method to invoke UI always in the correct thread.&lt;br /&gt;        private void InvokeInUIThread(Action action)&lt;br /&gt;        {&lt;br /&gt;            if (InvokeRequired)&lt;br /&gt;            {&lt;br /&gt;                Invoke(action);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                action.Invoke();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Wraps requests into one output channel.&lt;br /&gt;        // The service side listens to one address and uses unwrapper to unwrap&lt;br /&gt;        // messages and send them to correct receivers.&lt;br /&gt;        private IDuplexChannelWrapper myDuplexChannelWrapper;&lt;br /&gt;&lt;br /&gt;        // Message senders.&lt;br /&gt;        private IDuplexTypedMessageSender&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt; mySumSender;&lt;br /&gt;        private IDuplexTypedMessageSender&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt; mySubSender;&lt;br /&gt;        private IDuplexTypedMessageSender&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt; myMulSender;&lt;br /&gt;        private IDuplexTypedMessageSender&amp;lt;CalculatorOutputData, CalculatorInputData&amp;gt; myDivSender;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I hope you found this example useful. If you would like to read more technical details or you would need the online help you can use&lt;br /&gt;&lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;If you have any questions, do not hesitate to ask me.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-945763805423790719?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/945763805423790719/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/08/how-to-implement-service-receiving.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/945763805423790719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/945763805423790719'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/08/how-to-implement-service-receiving.html' title='How to Implement Service Receiving Requests via Messages'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-fnmepCenfJs/TiXAHrkCQII/AAAAAAAABKw/0F7TePM5rzs/s72-c/DuplexChannelUnwrapper.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-1547668314652852</id><published>2010-07-29T00:02:00.003+02:00</published><updated>2010-08-15T21:44:51.556+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Interprocess Communication</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; The article provides an overview about approaches for the interprocess communication.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;When you need to realize the communication between applications, usually you consider the following approaches:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;File Transfer&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Applications communicate via files. Producing applications write data to files and consuming applications read files to get data.&lt;br /&gt;&lt;br /&gt;The advantage is that applications are loosely coupled. They do not have to know about internal implementations of each other. They just need to know the file format and a location of files.&lt;br /&gt;&lt;br /&gt;On the other hand writing and reading files is not so fast. Therefore, files cannot be updated very frequently (e.g. many times per second) but usually they are updated in intervals, e.g. hourly. However, this causes delays and applications reading the file must often deal with the fact that data is not up to date -&amp;gt; synchronization issues.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Database Storage&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Applications communicate via shared data in a database. Share data is written into the database from where it can be read by other applications. &lt;br /&gt;&lt;br /&gt;The advantage is that the database provides a unified access to all data (e.g. via SQL). So applications do not have to deal with different file formats. In addition, the transaction mechanism helps to keep data consistent.&lt;br /&gt;&lt;br /&gt;The drawback is that applications using the database depends on the data schema. Therefore, the change in the data structure (data schema) can cause changes in applications using the database.&lt;br /&gt;&lt;br /&gt;Also the performance can be problematic - especially, if multiple applications frequently read and update the same data or the database is distributed across different locations.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Remote Procedure Call&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Applications communicate via exposed functionality. Application providing the functionality uses a middleware (e.g. WCF) to hide the interprocess communication. The intention is that remote calls look like local calls. The communication is usually synchronous.&lt;br /&gt;&lt;br /&gt;The advantage of this approach is that the application provides a specified functionality and encapsulates (hides) data.&lt;br /&gt;&lt;br /&gt;The disadvantage is that the communicating applications are coupled. E.g.:&lt;br /&gt;The calling application assumes that the other side implements the particular interface. If you add a new method to the interface, then all client applications are affected and must be updated and recompiled.&lt;br /&gt;&lt;br /&gt;Also the illusion that remote calls are same as local calls can be confusing. The problem is that the interprocess communication (especially across the network) is much slower and fails more often than simple local calls. To address these differences you may face to resolve issues that usually do not exist in local calls. E.g.:&lt;br /&gt;"How long can the call be blocked waiting for the response? Do you need some mechanism to cancel the call?"&lt;br /&gt;"What if the connection is broken? Do you need to reconnect and recover the call?"&lt;br /&gt;Therefore, although the Remote Procedure Call approach provides an abstraction that the communication between two applications is a simple local call, you cannot follow this idea because if you do not want to have troubles you cannot ignore specifics of the interprocess communication.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Messaging&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Applications communicate via messages. Communicating applications use a middleware (message oriented middleware) to send and receive messages. The sending application sends messages through the channel and the receiving application listens the channel to receive incoming messages. The communication is usually asynchronous. (I.e. the sending application is not blocked until the message is processed by the receiving application.)&lt;br /&gt;&lt;br /&gt;The advantage is that the communicating applications are loosely coupled. They do not have to know about internal implementations of each other. They just need to know the message format and the channel to send / receive the message.&lt;br /&gt;(If you add a new message, client applications are not affected.)&lt;br /&gt;&lt;br /&gt;Another advantage is that the service application provides a specified functionality and encapsulates (hides) data.&lt;br /&gt;(Request message invokes a functionality and response message returns results.)&lt;br /&gt;&lt;br /&gt;The price for the messaging communication is that the implementation deals with asynchronous programming. The asynchronous programming is more difficult and can add some complexity to the implementation.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;It is not possible to say that one communication approach is good and another is bad. All have its own pros and cons. The point is to choose approach (or combination of approaches) that fits the best the particular project. The communication needs should not be underestimated but also they should not be over-engineered with fancy technologies. Also a tendency applying always the same approach does not have to work - if the preferred approach does not fit then its using causes workarounds and additional complexity.&lt;br /&gt;Specifically, I have a feeling that for the interactive communication there is a tendency to prefer Remote Procedure Calls. But if coupling or synchronous approach should be problematic then Messaging could be a better alternative.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-1547668314652852?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/1547668314652852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/07/interprocess-communication.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/1547668314652852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/1547668314652852'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/07/interprocess-communication.html' title='Interprocess Communication'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-1208831158163710828</id><published>2010-07-18T18:30:00.006+02:00</published><updated>2011-07-19T19:27:11.843+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Silverlight: Notification Messages from the Server</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; The article shows how to implement receiving of notification messages from the hosting server in the Silverlight application with using Eneter.Messaging.Framework.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Basically there are two approaches, if you need to implement the communication scenario where the Silverlight client needs to be notified about some events on the server:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Polling&lt;/b&gt; &lt;br /&gt;The Silverlight client regularly initiates the Http connection and asks the server for messages. The server then responses messages intended for the client or returns an empty response if messages are not available (that can be the majority of requests).&lt;br /&gt;The advantage of the polling is that it does not block resources. (The problem is that browsers typically limit the number of concurrent Http connections per server to 2 - 8. The polling needs this connection only for short time.)&lt;br /&gt;The disadvantage of the polling is that it can cause a lot of useless communication. (In case the majority of requests return empty response.)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Pushing&lt;/b&gt;&lt;br /&gt;The Silverlight client initiates the Http connection. The server receives the request but does not answer until messages for the client are not available - the connection stays open (that can be long time). When the server answers, the client processes notifications and initiates the Http connection again.&lt;br /&gt;The advantage of the pushing is that there is not a useless communication.&lt;br /&gt;The disadvantage of the pushing is that it consumes the Http connection. And because browsers typically limit the number of concurrent Http connections per server to 2 - 8, it can happen that connections are occupied and the client application is blocked.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you prefer to get notification messages based on the pushing, you can choose WCF. The server can implement the service and the Silverlight client can get notification messages via some call-back interface.&lt;br /&gt;&lt;br /&gt;If you prefer to get notification messages based on the polling, you do not have many possibilities. Probably you would need to implement the communication in yourself with using .Net functionality for Http. (The client regularly polls and recognizes messages and the server constantly collects messages and responses them to the client on demand.)&lt;br /&gt;&lt;br /&gt;Another possibility you can consider is to use Eneter.Messaging.Framework. The framework provides a great support to implement the notification scenario based on polling.&lt;br /&gt;&lt;br /&gt;The example bellow shows how the Silverlight application can get notification messages with using Eneter.Messaging.Framework. The client subscribes to be notified from the server and server notifies the client when the event occurs. (In the example, the server generates numbers based on the timer.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;1. Server Site - ASP.NET Web Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;To use the messaging framework functionality you must add &lt;i&gt;Eneter.Messaging.Framework.dll&lt;/i&gt; into references. (Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;One of major responsibilities of the server in this communication scenario is to allow Silverlight clients to subscribe for messages. To support publish-subscribe scenario the framework provides the Broker component. The broker receives messages and sends them to subscribers.&lt;br /&gt;&lt;br /&gt;We also must ensure that Silverlight eneter messaging is properly connected with Asp.Net Server eneter messaging. To do so the server uses the Bridge component. (The bridge ensures the messages received as Http requests via 'Generic Handler' (ashx file) are correctly forwarded to the eneter messaging on the server site.)&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Timers;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.SynchronousMessagingSystem;&lt;br /&gt;using Eneter.Messaging.Nodes.Bridge;&lt;br /&gt;using Eneter.Messaging.Nodes.Broker;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;namespace SilverlightNotifiedFromAsp.Web&lt;br /&gt;{&lt;br /&gt;    public class Global : System.Web.HttpApplication&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        protected void Application_Start(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // MessagingSystem that will be used by the Silverlight-ASP messaging "bridge".&lt;br /&gt;            //myServerMessagingSystem = new ThreadMessagingSystemFactory();&lt;br /&gt;            myServerMessagingSystem = new SynchronousMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;            // Create the duplex input channel for the broker.&lt;br /&gt;            // Note: The broker will listen to this channel.&lt;br /&gt;            IDuplexInputChannel aBrokerDuplexInputChannel = myServerMessagingSystem.CreateDuplexInputChannel("BrokerChannel");&lt;br /&gt;&lt;br /&gt;            // Create broker.&lt;br /&gt;            // Because we communicate with Silverlight it must be XmlSerialization.&lt;br /&gt;            IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory(new XmlStringSerializer());&lt;br /&gt;            myBroker = aBrokerFactory.CreateBroker();&lt;br /&gt;            myBroker.AttachDuplexInputChannel(aBrokerDuplexInputChannel);&lt;br /&gt;&lt;br /&gt;            // Create the duplex output channel for the client that will send notifications.&lt;br /&gt;            IDuplexOutputChannel aClientDuplexOutputChannel = myServerMessagingSystem.CreateDuplexOutputChannel("BrokerChannel");&lt;br /&gt;&lt;br /&gt;            // Create sender of notification messages.&lt;br /&gt;            myBrokerClient = aBrokerFactory.CreateBrokerClient();&lt;br /&gt;            myBrokerClient.AttachDuplexOutputChannel(aClientDuplexOutputChannel);&lt;br /&gt;&lt;br /&gt;            // Create bridge to connect Silverligh with Asp&lt;br /&gt;            IBridgeFactory aBridgeFactory = new BridgeFactory();&lt;br /&gt;            myBridge = aBridgeFactory.CreateDuplexBridge(myServerMessagingSystem, "BrokerChannel");&lt;br /&gt;&lt;br /&gt;            // Store the bridge to be used from MessagingHandler.ashx.cs&lt;br /&gt;            Application["Bridge"] = myBridge;&lt;br /&gt;&lt;br /&gt;            // Start timer generating notification messages.&lt;br /&gt;            myTimer = new Timer(1000);&lt;br /&gt;            myTimer.AutoReset = false;&lt;br /&gt;            myTimer.Elapsed += OnTimerElapsed;&lt;br /&gt;            myTimer.Start();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected void Session_Start(object sender, EventArgs e){}&lt;br /&gt;&lt;br /&gt;        protected void Application_BeginRequest(object sender, EventArgs e){}&lt;br /&gt;&lt;br /&gt;        protected void Application_AuthenticateRequest(object sender, EventArgs e){}&lt;br /&gt;&lt;br /&gt;        protected void Application_Error(object sender, EventArgs e){}&lt;br /&gt;&lt;br /&gt;        protected void Session_End(object sender, EventArgs e){}&lt;br /&gt;&lt;br /&gt;        protected void Application_End(object sender, EventArgs e){}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // Generate the number and send the message to the broker.&lt;br /&gt;        private void OnTimerElapsed(object sender, ElapsedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            ++myNumber;&lt;br /&gt;&lt;br /&gt;            myBrokerClient.SendMessage("MyMessageType", myNumber);&lt;br /&gt;&lt;br /&gt;            myTimer.Start();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        private Timer myTimer;&lt;br /&gt;        private int myNumber = -1;&lt;br /&gt;&lt;br /&gt;        private IMessagingSystemFactory myServerMessagingSystem;&lt;br /&gt;&lt;br /&gt;        private IDuplexBroker myBroker;&lt;br /&gt;        private IDuplexBrokerClient myBrokerClient;&lt;br /&gt;&lt;br /&gt;        private IDuplexBridge myBridge;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The following code shows how to implement the generic handler (ashx) to receive messages from Silverlight eneter messaging system. It uses the bridge to forward incoming messages to the messaging system in the server.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System.Web;&lt;br /&gt;using Eneter.Messaging.Nodes.Bridge;&lt;br /&gt;&lt;br /&gt;namespace SilverlightNotifiedFromAsp.Web&lt;br /&gt;{&lt;br /&gt;    // Handles messaging communication with Silverlight clients.&lt;br /&gt;    public class MessagingHandler : IHttpHandler&lt;br /&gt;    {&lt;br /&gt;        public void ProcessRequest(HttpContext context)&lt;br /&gt;        {&lt;br /&gt;            context.Application.Lock();&lt;br /&gt;            &lt;br /&gt;            // Get the bridge to the broker and forward the message to the messaging system&lt;br /&gt;            // connected with the bridge.&lt;br /&gt;            IDuplexBridge aBridge = context.Application["Bridge"] as IDuplexBridge;&lt;br /&gt;            aBridge.ProcessRequestResponse(context.Request.InputStream, context.Response.OutputStream);&lt;br /&gt;            &lt;br /&gt;            context.Application.UnLock();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public bool IsReusable { get { return false; } }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;2. Client Site - Silverlight Application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;To use the messaging framework functionality you must add &lt;i&gt;Eneter.Messaging.Framework.Silverlight.dll&lt;/i&gt; into references. (Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;The client subscribes to be notified about generated numbers. The received messages are displayed in UI.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System.Windows;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.HttpMessagingSystem;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.Nodes.Broker;&lt;br /&gt;&lt;br /&gt;namespace SilverlightNotifiedFromAsp&lt;br /&gt;{&lt;br /&gt;    public partial class MainPage : UserControl&lt;br /&gt;    {&lt;br /&gt;        public MainPage()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create Http messaging for the specified message handler on the server side.&lt;br /&gt;            myHttpMessagingFactory = new HttpMessagingSystemFactory(1000);&lt;br /&gt;            string aChannelId = ServerUri.GetServerUri("/MessagingHandler.ashx");&lt;br /&gt;            IDuplexOutputChannel aDuplexOutputChannel = myHttpMessagingFactory.CreateDuplexOutputChannel(aChannelId);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            // Create broker client to receive notifications from the server.&lt;br /&gt;            IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory(new XmlStringSerializer());&lt;br /&gt;            myBrokerClient = aBrokerFactory.CreateBrokerClient();&lt;br /&gt;            myBrokerClient.BrokerMessageReceived += OnBrokerMessageReceived;&lt;br /&gt;            myBrokerClient.AttachDuplexOutputChannel(aDuplexOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Subscribes the broker receiver to get notifications from the server.&lt;br /&gt;        private void SubscribeBtn_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            string[] aMessageTypes = {"MyMessageType"};&lt;br /&gt;            myBrokerClient.Subscribe(aMessageTypes);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // Unsubscribes the broker message receiver.&lt;br /&gt;        private void UnsubscribeBtn_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myBrokerClient.Unsubscribe();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // Is called when the notification message from the broker is received.&lt;br /&gt;        private void OnBrokerMessageReceived(object sender, BrokerMessageReceivedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Display the message in the listbox.&lt;br /&gt;            MessagesList.Items.Insert(0, e.Message);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        private IMessagingSystemFactory myHttpMessagingFactory;&lt;br /&gt;        private IDuplexBrokerClient myBrokerClient;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;For the completeness here is the simple UI in Silverlight displaying generated numbers notified from the server.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-dsIVjf93Cg8/TiW-P07UXhI/AAAAAAAABKs/hZ7jMToUacc/s1600/NotifiedSilverlight.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-dsIVjf93Cg8/TiW-P07UXhI/AAAAAAAABKs/hZ7jMToUacc/s1600/NotifiedSilverlight.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I hope you found the article useful and you enjoyed the reading. If you would like to get more technical information you can visit &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Your feedback is always welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-1208831158163710828?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/1208831158163710828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/07/silverlight-notification-messages-from.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/1208831158163710828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/1208831158163710828'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/07/silverlight-notification-messages-from.html' title='Silverlight: Notification Messages from the Server'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-dsIVjf93Cg8/TiW-P07UXhI/AAAAAAAABKs/hZ7jMToUacc/s72-c/NotifiedSilverlight.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-2612793624927407620</id><published>2010-07-11T17:45:00.009+02:00</published><updated>2010-07-18T18:42:06.881+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Silverlight: Interprocess Communicatin from Silverlight Application</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; The article shows how to implement the communication between Silverlight application and some Non-Silverlight application with using Eneter.Messaging.Framework. The example shows Silverlight client invoking requests to the console application. The request can be paused, resumed or canceled.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;There are not many possibilities if you need to implement the communication between Silverlight application and some Non-Silverlight application (e.g. standard desktop application).&lt;br /&gt;Basically, you can choose sockets to implement your own communication based on Tcp or you can choose WCF to communicate via remote calls.&lt;br /&gt;&lt;br /&gt;Another option you can consider is to use Eneter.Messaging.Framework. The framework enables you to implement the message based communication scenarios. E.g. Silverlight client can invoke a request and manipulate it with 'pause', 'resume' and 'cancel'. It means the request being processed in the console application can be paused, resumed or canceled from Silverlight client.&lt;br /&gt;&lt;br /&gt;The example bellow shows how to implement the Silverlight client invoking a request to the Non-Silverlight application that can be 'paused', 'resumed' or 'canceled'.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;1. Create server - standard console application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Create standard console application in Visual Studio and add &lt;i&gt;Eneter.Messaging.Framework.dll&lt;/i&gt; to references.&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;Implement the main method the following way:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace TcpCommandServer&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Start policy server to allow the communication with the Silverlight client.&lt;br /&gt;            TcpPolicyServer aPolicyServer = new TcpPolicyServer(System.Net.IPAddress.Loopback);&lt;br /&gt;            aPolicyServer.StartPolicyServer();&lt;br /&gt;&lt;br /&gt;            // Create the communication based on Tcp.&lt;br /&gt;            // Note: Silverlight clients can communicate on the following ports: 4502 - 4532.&lt;br /&gt;            IMessagingSystemFactory aMessagingFactory = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel aDuplexInputChannel = aMessagingFactory.CreateDuplexInputChannel("127.0.0.1:4530");&lt;br /&gt;&lt;br /&gt;            // Start listening for requests.&lt;br /&gt;            CommandReceiver aCommandReceiver = new CommandReceiver();&lt;br /&gt;            aCommandReceiver.StartCommandReceiver(aDuplexInputChannel);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note: The policy server listens to port 943 and returns Xml telling to Silveright that the communication is allowed. The framework returns a basic Xml but you can also set your own if it is needed.&lt;br /&gt;&lt;br /&gt;Implement the CommandReceiver class responsible for processing requests.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Threading;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Sequencing;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.Commands;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;&lt;br /&gt;namespace TcpCommandServer&lt;br /&gt;{&lt;br /&gt;    public class TSomeRequestMessage&lt;br /&gt;    {&lt;br /&gt;        public string SomeParam1 { get; set; }&lt;br /&gt;        public int SomeParam2 { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public class TSomeResponseMessage&lt;br /&gt;    {&lt;br /&gt;        public int Progress { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    internal class CommandReceiver&lt;br /&gt;    {&lt;br /&gt;        public CommandReceiver()&lt;br /&gt;        {&lt;br /&gt;            // Silverlight does not support binary serialization.&lt;br /&gt;            // In Silverlight, the framework uses serialization to Xml by default.&lt;br /&gt;            // Therefore we must set here Xml serialization too.&lt;br /&gt;            ISerializer aSerializer = new XmlStringSerializer();&lt;br /&gt;&lt;br /&gt;            // Create command that puts incoming requests to the queue and&lt;br /&gt;            // processes them in one thread.&lt;br /&gt;            // CommandProcessingMethod - is the user provided method called to process the request.&lt;br /&gt;            ICommandsFactory aCommandsFactory = new CommandsFactory(aSerializer);&lt;br /&gt;            myCommand = aCommandsFactory.CreateCommand&amp;lt;TSomeResponseMessage, TSomeRequestMessage&amp;gt;(CommandProcessingMethod, EProcessingStrategy.SingleThread);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Starts listening to commands.&lt;br /&gt;        public void StartCommandReceiver(IDuplexInputChannel duplexInputChannel)&lt;br /&gt;        {&lt;br /&gt;            // Attach the duplex input channel to the command - the command starts the listening.&lt;br /&gt;            myCommand.AttachDuplexInputChannel(duplexInputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Stops listening.&lt;br /&gt;        public void StopCommandReceiver()&lt;br /&gt;        {&lt;br /&gt;            // Detach the input channel from the command.&lt;br /&gt;            // Note: If the input channel is not detached the thread processing command requests would leak&lt;br /&gt;            //       and prevent the closing the application.&lt;br /&gt;            myCommand.DetachDuplexInputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // This method is called when the command is executed.&lt;br /&gt;        private void CommandProcessingMethod(ICommandContext&amp;lt;TSomeResponseMessage, TSomeRequestMessage&amp;gt; commandContext)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                // Read the input data.&lt;br /&gt;                DataFragment&amp;lt;TSomeRequestMessage&amp;gt; anInputDataFragment = commandContext.DequeueInputData();&lt;br /&gt;                TSomeRequestMessage anInputData = anInputDataFragment.Data;&lt;br /&gt;&lt;br /&gt;                Console.WriteLine("Request received: " + anInputData.SomeParam1);&lt;br /&gt;&lt;br /&gt;                for (int i = 0; i &amp;lt; 100; ++i)&lt;br /&gt;                {&lt;br /&gt;                    // Simulate some work.&lt;br /&gt;                    Thread.Sleep(100);&lt;br /&gt;&lt;br /&gt;                    // Wait if pause is requested.&lt;br /&gt;                    if (commandContext.CurrentRequest == ECommandRequest.Pause)&lt;br /&gt;                    {&lt;br /&gt;                        // Notify the command proxy that the command was paused.&lt;br /&gt;                        commandContext.ResponsePause();&lt;br /&gt;&lt;br /&gt;                        // Wait until resumed or canceled.&lt;br /&gt;                        commandContext.WaitIfPause();&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    // If the cancel is requested then stop the command.&lt;br /&gt;                    if (commandContext.CurrentRequest == ECommandRequest.Cancel)&lt;br /&gt;                    {&lt;br /&gt;                        // Notify the command proxy that the command was canceled.&lt;br /&gt;                        commandContext.ResponseCancel();&lt;br /&gt;                        return;&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    // Create response message with the progress.&lt;br /&gt;                    TSomeResponseMessage aResponseMessage = new TSomeResponseMessage();&lt;br /&gt;                    aResponseMessage.Progress = i + 1;&lt;br /&gt;&lt;br /&gt;                    // Notify the progress.&lt;br /&gt;                    ECommandState aState = (i == 99) ? ECommandState.Completed : ECommandState.InProgress;&lt;br /&gt;                    commandContext.Response(aState, aResponseMessage);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            catch (Exception err)&lt;br /&gt;            {&lt;br /&gt;                commandContext.ResponseFailure(err.Message);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private ICommand&amp;lt;TSomeResponseMessage, TSomeRequestMessage&amp;gt; myCommand;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;2. Create client - Silverlight application&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Create Silverlight application in Visual Studio and add &lt;i&gt;Eneter.Messaging.Framework.Silverlight.dll&lt;/i&gt; to references.&lt;br /&gt;(Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;Implement the Silverlight client sending requests to the console application (server).&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System.Windows;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using Eneter.Messaging.EndPoints.Commands;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.TcpMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace SilverlightTcpCommandClient&lt;br /&gt;{&lt;br /&gt;    public class TSomeRequestMessage&lt;br /&gt;    {&lt;br /&gt;        public string SomeParam1 { get; set; }&lt;br /&gt;        public int SomeParam2 { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public class TSomeResponseMessage&lt;br /&gt;    {&lt;br /&gt;        public int Progress { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public partial class MainPage : UserControl&lt;br /&gt;    {&lt;br /&gt;        public MainPage()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create messaging system to send messages to the command.&lt;br /&gt;            // Note: It can be any messaging system but in this case is the fastest one is Synchronous.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();&lt;br /&gt;            IDuplexOutputChannel anOutputChannel = aMessaging.CreateDuplexOutputChannel("127.0.0.1:4530");&lt;br /&gt;&lt;br /&gt;            // Create command proxy to send requests and receive responses.&lt;br /&gt;            // The command responses progress &lt;br /&gt;            ICommandsFactory aCommandsFactory = new CommandsFactory();&lt;br /&gt;            myCommandProxy = aCommandsFactory.CreateCommandProxy&amp;lt;TSomeResponseMessage, TSomeRequestMessage&amp;gt;();&lt;br /&gt;            myCommandProxy.CommandResponseReceived += OnCommandResponseReceived;&lt;br /&gt;&lt;br /&gt;            // Attach the output channel to the command proxy and enable sending of requests.&lt;br /&gt;            myCommandProxy.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void ExecuteBtn_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Create the message.&lt;br /&gt;            TSomeRequestMessage aRequestMessage = new TSomeRequestMessage();&lt;br /&gt;            aRequestMessage.SomeParam1 = "Some text.";&lt;br /&gt;            aRequestMessage.SomeParam2 = 100;&lt;br /&gt;&lt;br /&gt;            // Execute the command.&lt;br /&gt;            myCommandProxy.Execute("MyCommandId", aRequestMessage);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void PauseBtn_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myCommandProxy.Pause("MyCommandId");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void ResumeBtn_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myCommandProxy.Resume("MyCommandId");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void CancelBtn_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            myCommandProxy.Cancel("MyCommandId");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OnCommandResponseReceived(object sender, CommandResponseReceivedEventArgs&amp;lt;TSomeResponseMessage&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // Display the progress from incomming response message.&lt;br /&gt;            if (e.CommandState == ECommandState.InProgress)&lt;br /&gt;            {&lt;br /&gt;                myProgressBar.Value = e.ReturnData.Progress;&lt;br /&gt;            }&lt;br /&gt;            else if (e.CommandState == ECommandState.Canceled ||&lt;br /&gt;                     e.CommandState == ECommandState.Completed)&lt;br /&gt;            {&lt;br /&gt;                myProgressBar.Value = 0;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private ICommandProxy&amp;lt;TSomeResponseMessage, TSomeRequestMessage&amp;gt; myCommandProxy;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;For sake of completeness here is the Xaml file for the Silverlight client defining buttons and progress bar.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;&amp;lt;UserControl x:Class="SilverlightTcpCommandClient.MainPage"&lt;br /&gt;    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;br /&gt;    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&lt;br /&gt;    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"&lt;br /&gt;    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;br /&gt;    mc:Ignorable="d"&lt;br /&gt;    d:DesignHeight="300" d:DesignWidth="400"&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;Grid x:Name="LayoutRoot" Background="White" Height="181" Width="273"&amp;gt;&lt;br /&gt;        &amp;lt;Button Content="Execute Task" Height="23" HorizontalAlignment="Left" Margin="28,35,0,0" Name="ExecuteBtn" VerticalAlignment="Top" Width="89" Click="ExecuteBtn_Click" /&amp;gt;&lt;br /&gt;        &amp;lt;Button Content="Pause" Height="23" HorizontalAlignment="Left" Margin="179,35,0,0" Name="PauseBtn" VerticalAlignment="Top" Width="75" Click="PauseBtn_Click" /&amp;gt;&lt;br /&gt;        &amp;lt;Button Content="Resume" Height="23" HorizontalAlignment="Left" Margin="179,64,0,0" Name="ResumeBtn" VerticalAlignment="Top" Width="75" Click="ResumeBtn_Click" /&amp;gt;&lt;br /&gt;        &amp;lt;Button Content="Cancel" Height="23" HorizontalAlignment="Left" Margin="179,93,0,0" Name="CancelBtn" VerticalAlignment="Top" Width="75" Click="CancelBtn_Click" /&amp;gt;&lt;br /&gt;        &amp;lt;ProgressBar Height="22" HorizontalAlignment="Left" Margin="28,138,0,0" Name="myProgressBar" VerticalAlignment="Top" Width="226" /&amp;gt;&lt;br /&gt;    &amp;lt;/Grid&amp;gt;&lt;br /&gt;&amp;lt;/UserControl&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As you can see the implementation requires just little coding. I hope you like my posts about Eneter.Messaging.Framework. I am going to write more articles. If you are interested in more technical information you can try here:&lt;br /&gt;&lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-2612793624927407620?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/2612793624927407620/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/07/silverlight-interprocess-communicatin.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/2612793624927407620'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/2612793624927407620'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/07/silverlight-interprocess-communicatin.html' title='Silverlight: Interprocess Communicatin from Silverlight Application'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-7417887219822877906</id><published>2010-07-10T00:43:00.006+02:00</published><updated>2010-07-18T18:41:26.399+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Silverlight: Comunication between Silverlight Applications with Typed Messages</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; The article shows how to use Eneter.Messaging.Framework for the communication between Silverlight applications to send typed messages (no size limitation).&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;Silverlight is a nice technology with many useful features to develop cool web-applications. But if you want to communicate between Silverlight applications the possibilities are very limited. Silverlight supports only string messages with limited size (max 40 kilobytes long). If the communication scenario is very simple this basic possibilities can be sufficient. But if your communication needs to recognize between different messages, or you need to communicate request-response with different message types, or you just need messages bigger than 40 KB then the basic Silverlight messaging is not sufficient and you must implement the whole communication "plumbing" in yourself.&lt;br /&gt;&lt;br /&gt;Eneter.Messaging.Framework provides a lot of possibilities for the communication between Silverlight applications. For the beginning I would like to show how to use the framework to overcome the known limitations of Silverlight.&lt;br /&gt;&lt;br /&gt;The example bellow shows how to send messages of desired type from one silverlight application to another.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;1. Add &lt;i&gt;Eneter.Messaging.Framework.Silverlight.dll&lt;/i&gt;&lt;/b&gt;&lt;/span&gt; into your Silverlight applications references to use the messaging functionality. (Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;2. Implement Silverlight application receiving typed messages.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The code with using the framework is very simple:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System.Collections.ObjectModel;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.SilverlightMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace StrongTypeReceiver&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public partial class MainPage : UserControl&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Data type to be sent as the message.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public class BasketItem&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Id { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Price { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public MainPage()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Initialize your UI.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BasketItems.ItemsSource = myBasketItems;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create input channel to receive message from Silverlight.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Note: The channel id (in our case BasketId) represents the address of the receiver.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IMessagingSystemFactory aMessagingFactory = new SilverlightMessagingSystemFactory();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IInputChannel anInputChannel = aMessagingFactory.CreateInputChannel("BasketId");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Instantiate strong typed receiver.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ITypedMessagesFactory aTypedMessagesFactory = new TypedMessagesFactory();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTypedMessageReceiver = aTypedMessagesFactory.CreateTypedMessageReceiver&amp;lt;BasketItem&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Handler for received messages.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTypedMessageReceiver.MessageReceived += OnTypedMessageReceived;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Attach input channel and listen.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTypedMessageReceiver.AttachInputChannel(anInputChannel);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Processes the recived message - the message is of type BasketItem.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void OnTypedMessageReceived(object sender, TypedMessageReceivedEventArgs&amp;lt;BasketItem&amp;gt; e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Store received data into a collection observed by your UI.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myBasketItems.Add(e.MessageData);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private ObservableCollection&amp;lt;BasketItem&amp;gt; myBasketItems = new ObservableCollection&amp;lt;BasketItem&amp;gt;();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Strong typed message receiver.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private ITypedMessageReceiver&amp;lt;BasketItem&amp;gt; myTypedMessageReceiver;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;3. Implement Silverlight application sending typed messages.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The sender side (client) is very simple too.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System.Windows;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.SilverlightMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace StrongTypeSender&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public partial class MainPage : UserControl&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Data structure to be sent.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public class BasketItem&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Id { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Price { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public MainPage()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create output channel to send message via Silverlight.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Note: Use the same channel id (address) as receiver.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IMessagingSystemFactory aMessagingFactory = new SilverlightMessagingSystemFactory();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IOutputChannel anOutputChannel = aMessagingFactory.CreateOutputChannel("BasketId");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Instantiate strong typed sender.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ITypedMessagesFactory aTypedMessagesFactory = new TypedMessagesFactory();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTypedMessageSender = aTypedMessagesFactory.CreateTypedMessageSender&amp;lt;BasketItem&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTypedMessageSender.AttachOutputChannel(anOutputChannel);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void SendButton_Click(object sender, RoutedEventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BasketItem aBasketItem = new BasketItem();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aBasketItem.Id = IdTextBox.Text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aBasketItem.Name = NameTextBox.Text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int aPrice;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (int.TryParse(PriceTextBox.Text, out aPrice))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aBasketItem.Price = aPrice;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Send the the message.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myTypedMessageSender.SendMessage(aBasketItem);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Strong typed message sender.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private ITypedMessageSender&amp;lt;BasketItem&amp;gt; myTypedMessageSender;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This is really all what you need if you use the framework.&lt;br /&gt;&lt;br /&gt;Eneter.Messaging.Framework has much more capabilities as described above. It offers also request-response communication, well defined components (e.g Broker for publish-subscribe communication), ... .&lt;br /&gt;The same framework can be used for communication between the Silverlight application and the hosting server. And the same framework can be also used to implement the message based communication between threads inside the Silverlight application.&lt;br /&gt;I will write more articles about the communication based on this platform.&lt;br /&gt;&lt;br /&gt;Would you like to know more technical details about this platform, you can read here:&amp;nbsp; &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-7417887219822877906?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/7417887219822877906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/07/silverlight-comunication-between.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/7417887219822877906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/7417887219822877906'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/07/silverlight-comunication-between.html' title='Silverlight: Comunication between Silverlight Applications with Typed Messages'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-1170675248324557933</id><published>2010-07-06T22:35:00.036+02:00</published><updated>2011-07-19T19:22:15.262+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Request-Response Communication</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; Simple example showing how to implement the request-response communication between applications.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrej_Uzovic%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;The request-response communication is a communication scenario where messages flow in both directions - request messages from the sender to the receiver and response messages from the receiver back to the sender. &lt;br /&gt;&lt;br /&gt;The example bellow shows the server receiving messages and sending responses back to the client. It also shows how to implement the client sending messages to the server and receiving response messages.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;1. Add &lt;i&gt;Eneter.Messaging.Framework.dll&lt;/i&gt;&lt;/b&gt;&lt;/span&gt; to use the messaging  functionality in your .Net applications. (Full, not limited and for  non-commercial usage free version of the framework can be downloaded  from &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;2. Define message types.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;For the request-response communication you must define type of the request message and type of the response message.&lt;br /&gt;And same as described in the &lt;a href="http://eneter.blogspot.com/2010/07/enetermessagingframework-1.html"&gt;previous part&lt;/a&gt;, you should consider what serialization will be used.&lt;br /&gt;(Because the serialization can require some additional attributes in the declarations.)&lt;br /&gt;&lt;br /&gt;In our example we will use the binary serialization. The request message type is 'Person' and the response type is the string.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using CommonTypes;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.NamedPipeMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace DuplexTypedMessageServer&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        // Duplex typed message receicer that receives type Person and responses type string.&lt;br /&gt;        static IDuplexTypedMessageReceiver&amp;lt;string, Person&amp;gt; myMessageReceiver;&lt;br /&gt;&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Create factory to create input channel based on Named Pipes&lt;br /&gt;            IMessagingSystemFactory aMessagingSystemFactory = new NamedPipeMessagingSystemFactory();&lt;br /&gt;            IDuplexInputChannel anDuplexInputChannel =&lt;br /&gt;                aMessagingSystemFactory.CreateDuplexInputChannel("//127.0.0.1/MyPipeName3");&lt;br /&gt;&lt;br /&gt;            // Create duplex typed message receiver using the binary serialization.&lt;br /&gt;            ISerializer aSerializer = new BinarySerializer();&lt;br /&gt;            IDuplexTypedMessagesFactory aDuplexTypedMessagesFactory =&lt;br /&gt;                new DuplexTypedMessagesFactory(aSerializer);&lt;br /&gt;            myMessageReceiver = aDuplexTypedMessagesFactory.CreateDuplexTypedMessageReceiver&amp;lt;string, Person&amp;gt;();&lt;br /&gt;            myMessageReceiver.MessageReceived += OnMessageReceived;&lt;br /&gt;&lt;br /&gt;            // Attach the input channel to the string message receiver and start listening.&lt;br /&gt;            myMessageReceiver.AttachDuplexInputChannel(anDuplexInputChannel);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("The service is listening. Press enter to stop.\n");&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&gt;            myMessageReceiver.DetachDuplexInputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        static void OnMessageReceived(object sender, TypedRequestReceivedEventArgs&amp;lt;Person&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            Console.WriteLine("Received Message:");&lt;br /&gt;            Console.WriteLine("Name: " + e.RequestMessage.Name);&lt;br /&gt;            Console.WriteLine("Number of items: " + e.RequestMessage.NumberOfItems.ToString());&lt;br /&gt;            Console.WriteLine();&lt;br /&gt;&lt;br /&gt;            // As a response send the current time.&lt;br /&gt;            string aResponseMessage = DateTime.Now.ToString();&lt;br /&gt;            myMessageReceiver.SendResponseMessage(e.ResponseReceiverId, aResponseMessage);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;4. Implement the client.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The client bellow sends the message type of 'Person' and receives the response message type of string.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using CommonTypes;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.NamedPipeMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace DuplexTypedMessageClient&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        // Duplex typed message sender that sends type Person and&lt;br /&gt;        // receives responses of type string.&lt;br /&gt;        private IDuplexTypedMessageSender&amp;lt;string, Person&amp;gt; myMessageSender;&lt;br /&gt;&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            OpenConnection();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OpenConnection()&lt;br /&gt;        {&lt;br /&gt;            // Create factory to create input channel based on Named Pipes&lt;br /&gt;            IMessagingSystemFactory aMessagingSystemFactory = new NamedPipeMessagingSystemFactory();&lt;br /&gt;            IDuplexOutputChannel anOutputChannel =&lt;br /&gt;                aMessagingSystemFactory.CreateDuplexOutputChannel("//127.0.0.1/MyPipeName3");&lt;br /&gt;&lt;br /&gt;            // Create duplex typed message sender that uses the binnary serializer.&lt;br /&gt;            ISerializer aSerializer = new BinarySerializer();&lt;br /&gt;            IDuplexTypedMessagesFactory aDuplexTypedMessagesFactory =&lt;br /&gt;                new DuplexTypedMessagesFactory(aSerializer);&lt;br /&gt;            myMessageSender = aDuplexTypedMessagesFactory.CreateDuplexTypedMessageSender&amp;lt;string, Person&amp;gt;();&lt;br /&gt;            myMessageSender.ResponseReceived += OnResponseReceived;&lt;br /&gt;&lt;br /&gt;            // Attach duplex output channel and be able to send messages&lt;br /&gt;            // and receive response messages.&lt;br /&gt;            myMessageSender.AttachDuplexOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Form1_FormClosed(object sender, FormClosedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Correctly close connection.&lt;br /&gt;            // Otherwise the thread listening to response messages will leak.&lt;br /&gt;            myMessageSender.DetachDuplexOutputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void button1_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Prepare the message.&lt;br /&gt;            Person aPerson = new Person();&lt;br /&gt;            aPerson.Name = NameTextBox.Text;&lt;br /&gt;            aPerson.NumberOfItems = int.Parse(NumberOfItemsTextBox.Text);&lt;br /&gt;&lt;br /&gt;            // Send the message.&lt;br /&gt;            myMessageSender.SendRequestMessage(aPerson);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void OnResponseReceived(object sender, TypedResponseReceivedEventArgs&amp;lt;string&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            string aResponseMessage = e.ResponseMessage;&lt;br /&gt;            InvokeInUIThread(() =&amp;gt; ReceivedResponseTextBox.Text = aResponseMessage);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Helper method to invoke the given delegate&lt;br /&gt;        // in the UI thread.&lt;br /&gt;        private void InvokeInUIThread(Action action)&lt;br /&gt;        {&lt;br /&gt;            if (InvokeRequired)&lt;br /&gt;            {&lt;br /&gt;                Invoke(action);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                action();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And here are communicating applications.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-GC-PoUZ7YqM/TiW9L0kEOCI/AAAAAAAABKo/MljVpEM-fIc/s1600/RequestResponseApplications.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-GC-PoUZ7YqM/TiW9L0kEOCI/AAAAAAAABKo/MljVpEM-fIc/s1600/RequestResponseApplications.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-mfBswN6FmcM/TeFO1BarK9I/AAAAAAAABGE/hDE_xRTPYT4/s1600/RequestResponseApplications.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-1170675248324557933?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/1170675248324557933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/07/how-to-enetermessagingframework-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/1170675248324557933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/1170675248324557933'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/07/how-to-enetermessagingframework-2.html' title='Request-Response Communication'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-GC-PoUZ7YqM/TiW9L0kEOCI/AAAAAAAABKo/MljVpEM-fIc/s72-c/RequestResponseApplications.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-8158062706003212341</id><published>2010-07-04T12:29:00.099+02:00</published><updated>2011-07-19T19:20:32.115+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>One-Way Communication</title><content type='html'>&lt;b&gt;Summary:&lt;/b&gt; Simple example showing how to implement the one-way communication between applications.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;The one-way communication is a communication scenario where messages flow only in one direction - from sender to receiver.Although the scenario sounds simple it can be quite complex programming if you use just default .Net functionality (e.g. sockets). To simplify the implementation and reduce the effort you would probably consider to use some communication framework.&lt;br /&gt;&lt;br /&gt;I would like to show you how the one-way communication with typed messages works with Eneter.Messaging.Framework.&lt;br /&gt;The example shows, how to implement the server receiving messages of the specified type and the client sending messages of the same type.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;1. Add &lt;i&gt;Eneter.Messaging.Framework.dll&lt;/i&gt;&lt;/b&gt;&lt;/span&gt; to use the messaging functionality in your .Net applications. (Full, not limited and for non-commercial usage free version of the framework can be downloaded from &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;2. Define message types&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;You need to define message types you want to use for the communication. Because the serialization and deserialization (used during sending and receiving) can require some additional attributes in the declaration of the type you also should consider what serialization will be used.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Binary Serialization&lt;/i&gt;&lt;br /&gt;The data is serialized into array of bytes. The serialization is fast and consumes less memory as string serializations.&lt;br /&gt;It requires to use 'Serializable' attribute and the data must be declared in an assembly that is linked by the server and also by the client.&lt;br /&gt;(Here you can consider to create some assembly for shared data types.)&lt;br /&gt;The binary serialization is not supported by Silverlight.&lt;br /&gt;The serialization is based on BinaryFormater provided by .Net platform.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Xml Serialization&lt;/i&gt;&lt;br /&gt;The data is serialized into the string. The serialization is slower and consumes more memory as the binary serialization.&lt;br /&gt;It does not require, the server and the client link the same assembly with data types. The data can be declared separately on both sides.&lt;br /&gt;The xml serialization works in Silverlight too.&lt;br /&gt;The serialization is based on XmlSerializer provided by .Net platform..&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Data Contract Serialization&lt;/i&gt;&lt;br /&gt;The data is serialized as Xml into the string. The serialization is based DataContractSerializer provided by .Net platform. Therefore, you can use all data contract attributes to declare the data for the serialization / deserialization.&lt;br /&gt;&lt;br /&gt;Our example uses the binary serialization, therefore here is the declaration for our message.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;&lt;br /&gt;namespace CommonTypes&lt;br /&gt;{&lt;br /&gt;    [Serializable]&lt;br /&gt;    public class Person&lt;br /&gt;    {&lt;br /&gt;        public string Name { get; set; }&lt;br /&gt;        public int NumberOfItems { get; set; }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;3. Implement the server&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;When you implement the interprocess communication you must choose if you want to communicate via Named Pipes, Tcp or Http protocol.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Named Pipes&lt;/i&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;// Create factory for messaging via Named Pipes.&lt;br /&gt;IMessagingSystemFactory aMessagingSystemFactory =&lt;br /&gt;new NamedPipeMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;// Create input channel for listening to messages.&lt;br /&gt;IInputChannel anInputChannel =&lt;br /&gt;aMessagingSystemFactory.CreateInputChannel("//127.0.0.1/MyPipeName2");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;i&gt;Tcp&lt;/i&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;// Create factory for messaging via Tcp.&lt;br /&gt;IMessagingSystemFactory aMessagingSystemFactory =&lt;br /&gt;new TcpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;// Create input channel for listening to messages.&lt;br /&gt;IInputChannel anInputChannel = aMessagingSystemFactory.CreateInputChannel("127.0.0.1:8091");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;i&gt;Http&lt;/i&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;// Create factory for messaging via Http.&lt;br /&gt;IMessagingSystemFactory aMessagingSystemFactory =&lt;br /&gt;new HttpMessagingSystemFactory();&lt;br /&gt;&lt;br /&gt;// Create input channel for listening to messages.&lt;br /&gt;IInputChannel anInputChannel =&lt;br /&gt;aMessagingSystemFactory.CreateInputChannel("127.0.0.1:8091");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Let's use Named Pipes in our example.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using CommonTypes;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.NamedPipeMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace TypedMessageServer&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        // Strong type receiver for the type Person.&lt;br /&gt;        static private ITypedMessageReceiver&amp;lt;Person&amp;gt; myReceiver;&lt;br /&gt;&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            // Create receiver for the message type 'Person' with binary serializer.&lt;br /&gt;            ISerializer aSerializer = new BinarySerializer();&lt;br /&gt;            ITypedMessagesFactory aTypedMessagesFactory = new TypedMessagesFactory(aSerializer);&lt;br /&gt;            myReceiver = aTypedMessagesFactory.CreateTypedMessageReceiver&amp;lt;Person&amp;gt;();&lt;br /&gt;            myReceiver.MessageReceived += OnMessageReceived;&lt;br /&gt;&lt;br /&gt;            // Create input channel listening to Named Pipe.&lt;br /&gt;            // Note: This is a one-way channel. Therefore, it can just receive messages.&lt;br /&gt;            // Note: Do not use '/' at the end of the address.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new NamedPipeMessagingSystemFactory();&lt;br /&gt;            IInputChannel anInputChannel = aMessaging.CreateInputChannel("//127.0.0.1/MyPipeName2");&lt;br /&gt;&lt;br /&gt;            // Attach input channel ans start listening.&lt;br /&gt;            myReceiver.AttachInputChannel(anInputChannel);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine("The service is listening. Press enter to stop.\n");&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&gt;            myReceiver.DetachInputChannel();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        static void OnMessageReceived(object sender, TypedMessageReceivedEventArgs&amp;lt;Person&amp;gt; e)&lt;br /&gt;        {&lt;br /&gt;            // If there was a problem with the receiving.&lt;br /&gt;            if (e.ReceivingError != null)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine("Detected problem during receiving: " + e.ReceivingError.Message);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine("Received Message:");&lt;br /&gt;                Console.WriteLine("Name: " + e.MessageData.Name);&lt;br /&gt;                Console.WriteLine("Number of items: " + e.MessageData.NumberOfItems.ToString());&lt;br /&gt;                Console.WriteLine();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;4. Implement the client&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;And here is the implementation for the client sending messages of type Person.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using CommonTypes;&lt;br /&gt;using Eneter.Messaging.DataProcessing.Serializing;&lt;br /&gt;using Eneter.Messaging.EndPoints.TypedMessages;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.MessagingSystemBase;&lt;br /&gt;using Eneter.Messaging.MessagingSystems.NamedPipeMessagingSystem;&lt;br /&gt;&lt;br /&gt;namespace TypedMessageClient&lt;br /&gt;{&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;        private ITypedMessageSender&amp;lt;Person&amp;gt; myMessageSender;&lt;br /&gt;&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // Create input channel listening to Named Pipe.&lt;br /&gt;            // Note: This is a one-way channel. Therefore, it can just receive messages.&lt;br /&gt;            IMessagingSystemFactory aMessaging = new NamedPipeMessagingSystemFactory();&lt;br /&gt;            IOutputChannel anOutputChannel = aMessaging.CreateOutputChannel("//127.0.0.1/MyPipeName2");&lt;br /&gt;&lt;br /&gt;            // Create the message sender sending the class of type 'Person'.&lt;br /&gt;            // The sender will use the binary serializer.&lt;br /&gt;            ISerializer aSerializer = new BinarySerializer();&lt;br /&gt;            ITypedMessagesFactory aTypedMessagesFactory = new TypedMessagesFactory(aSerializer);&lt;br /&gt;            myMessageSender = aTypedMessagesFactory.CreateTypedMessageSender&amp;lt;Person&amp;gt;();&lt;br /&gt;&lt;br /&gt;            // Attach the output channel and be able to send messages.&lt;br /&gt;            myMessageSender.AttachOutputChannel(anOutputChannel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void SendButton_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // Prepare the message.&lt;br /&gt;            Person aPerson = new Person();&lt;br /&gt;            aPerson.Name = NameTextBox.Text;&lt;br /&gt;            aPerson.NumberOfItems = int.Parse(NumberOfItemsTextBox.Text);&lt;br /&gt;&lt;br /&gt;            // Send the message.&lt;br /&gt;            myMessageSender.SendMessage(aPerson);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And here are communicating applications.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-qcw-PHQbpLk/TiW8xK2GmhI/AAAAAAAABKk/8JcgonzH52g/s1600/OneWayCommunicationApplications.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-qcw-PHQbpLk/TiW8xK2GmhI/AAAAAAAABKk/8JcgonzH52g/s1600/OneWayCommunicationApplications.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-rpjwExxcim4/TeE62P9n42I/AAAAAAAABGA/HfnfyYo52Sk/s1600/OneWayCommunicationApplications.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-8158062706003212341?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/8158062706003212341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/07/enetermessagingframework-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/8158062706003212341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/8158062706003212341'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/07/enetermessagingframework-1.html' title='One-Way Communication'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-qcw-PHQbpLk/TiW8xK2GmhI/AAAAAAAABKk/8JcgonzH52g/s72-c/OneWayCommunicationApplications.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-4845611393974575404</id><published>2010-07-03T11:15:00.013+02:00</published><updated>2011-07-19T19:18:44.676+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Communication'/><title type='text'>Eneter.Messaging.Framework 1.0</title><content type='html'>&lt;div&gt;The article briefly describes &lt;span style="color: #660000;"&gt;Eneter.Messaging.Framework version 1.0&lt;/span&gt; as a platform for the communication between applications.&lt;br /&gt;&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=%3COndrejUzo%3E" rel="tag" style="display: none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;This article describes the first version of the framework. The latest version you can find here: &lt;/div&gt;&lt;div&gt;&lt;a href="http://eneter.blogspot.com/2011/03/eneter-messaging-framework-20.html"&gt;Eneter Messaging Framework version 2.0&lt;/a&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Applications typically do not run isolated but they communicate to each other. Also internally the application can consist of components or layers (running in different threads) that need to communicate. Dealing with different technologies, communication protocols and possibilities how to resolve the communication between applications and inside the application adds the complexity and increases the effort.&lt;br /&gt;&lt;span style="color: #990000;"&gt;Eneter.Messaging.Framework&lt;/span&gt; is the message oriented middleware providing the unified approach for communication with messages. It means, you use the same functionality to communicate between processes and between components inside the process.&lt;br /&gt;&lt;br /&gt;The framework wraps the communication protocols and technologies for you and provides well defined components you can use to realize communication scenarios.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-J7VpjlWScOM/TiW8AsP0mZI/AAAAAAAABKg/fEYg3WZmu1I/s1600/EneterComponents.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/-J7VpjlWScOM/TiW8AsP0mZI/AAAAAAAABKg/fEYg3WZmu1I/s640/EneterComponents.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;For the interprocess communication, the framework supports:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Named Pipes&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;TCP&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Http&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Silverlight Messaging&lt;/b&gt;&amp;nbsp; (yes, you can use it for Silverlight applications too)&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;For the communication inside the application, the framework supports:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Synchronous messaging&lt;/b&gt; - messages processed in the context of caller thread.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Thread messaging&lt;/b&gt; - messages for one processing thread.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Thread Pool messaging&lt;/b&gt; - messages for more processing threads.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;The communication can be one-way or request-response. It can be string messages or strongly typed messages.&lt;br /&gt;&lt;br /&gt;And you can use the following components to create your communication scenario:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Bridge&lt;/b&gt; - connects messaging systems.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Broker&lt;/b&gt; - receives messages and forwards them to subscribed receivers.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Router&lt;/b&gt; - receives messages and forwards them to preconfigured receivers.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Dispatcher&lt;/b&gt; - receives messages and forwards them to all receivers.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Channel Wrapper&lt;/b&gt; - wraps messages from more channels and sends via one channel&lt;/li&gt;&lt;li&gt;&lt;b&gt;Channel Unwrapper&lt;/b&gt; - unwraps messages from one channel and sends them to respective channels.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;For more technical details, please refer to &lt;a href="http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html"&gt;http://www.eneter.net/OnlineHelp/EneterMessagingFramework/Index.html&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-4845611393974575404?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/4845611393974575404/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/07/enetermessagingframework.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/4845611393974575404'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/4845611393974575404'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/07/enetermessagingframework.html' title='Eneter.Messaging.Framework 1.0'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-J7VpjlWScOM/TiW8AsP0mZI/AAAAAAAABKg/fEYg3WZmu1I/s72-c/EneterComponents.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5196103582241137578.post-933468118785895212</id><published>2010-07-03T00:26:00.006+02:00</published><updated>2010-07-04T12:45:59.651+02:00</updated><title type='text'>Beginning</title><content type='html'>Today I am starting the web-page &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt;. The page is dedicated to the software development and will offer various solutions for challenges we frequently experience during the software development.&lt;br /&gt;&lt;br /&gt;The intention is, solutions are lightweight, easy to use and will reduce the complexity of your development. To support developers, there is also the online documentation with examples.&lt;br /&gt;&lt;br /&gt;The software is offered for free for non-commercial purposes. The commercial usage requires the license you can obtain for the fair price. (Please refer to the license agreement on the page.)&lt;br /&gt;&lt;br /&gt;I invite you to visit &lt;a href="http://www.eneter.net/"&gt;www.eneter.net&lt;/a&gt; and I hope you will download the software, find it useful and send me your feedback.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5196103582241137578-933468118785895212?l=eneter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://eneter.blogspot.com/feeds/933468118785895212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://eneter.blogspot.com/2010/07/today-i-am-starting-web-page-www.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/933468118785895212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5196103582241137578/posts/default/933468118785895212'/><link rel='alternate' type='text/html' href='http://eneter.blogspot.com/2010/07/today-i-am-starting-web-page-www.html' title='Beginning'/><author><name>Ondrej Uzovic</name><uri>http://www.blogger.com/profile/11029096061173289386</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/-VW1jmMRWTEk/TiSbPjWdu8I/AAAAAAAABJM/SzAoeroiP1Y/s220/IMG_2060.gif'/></author><thr:total>0</thr:total></entry></feed>
