Advertisement
Guest User

Untitled

a guest
Sep 1st, 2010
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.26 KB | None | 0 0
  1. using System;
  2. using Microsoft.Axum;
  3. using System.Concurrency.Messaging;
  4. using System.ServiceModel;
  5.  
  6. namespace SimpleDistro
  7. {
  8.     channel Simple
  9.     {
  10.         input string InputMessage;
  11.         output string OutputMessage;
  12.     }
  13.    
  14.     domain ServiceDomain
  15.     {
  16.         public agent ServiceAgent : channel Simple
  17.         {
  18.             public ServiceAgent ()
  19.             {
  20.                 // Do something useful.
  21.                 string message = receive(PrimaryChannel::InputMessage);
  22.                 PrimaryChannel::OutputMessage <-- message;
  23.             }
  24.         }
  25.     }
  26.    
  27.     public domain Program
  28.     {
  29.         agent Server : channel Microsoft.Axum.Application
  30.         {
  31.             public Server()
  32.             {
  33.                 String [] args = receive(PrimaryChannel::CommandLine);
  34.                
  35.                 var auctionAddr = "net.tcp://localhost:4711/simpleService1";
  36.                
  37.                 bool isServer = (args.Length > 0 && args[0] == "server");
  38.                
  39.                 if(isServer)
  40.         {
  41.             var hst = new TcpServiceHost();
  42.                     //var hst = new WcfServiceHost(new NetTcpBinding(SecurityMode.None, false));
  43.                     hst.Host<ServiceDomain.ServiceAgent>(auctionAddr, new ServiceDomain());
  44.                 }
  45.  
  46.                 var prov = new TcpCommunicationProvider();
  47.         //var prov = new WcfCommunicationProvider(new NetTcpBinding(SecurityMode.None, false));
  48.         var chan = prov.Connect<Simple>(auctionAddr);
  49.                                                  
  50.                 if(isServer)
  51.                 {
  52.                     Console.WriteLine("Server started.");
  53.                    
  54.                     while(true)
  55.                     {
  56.             var msg = receive(chan::OutputMessage); // <------- NEVER RECEIVING!
  57.                         Console.WriteLine(msg);                    
  58.                     }
  59.         }
  60.                 else
  61.                 {
  62.                     Console.WriteLine("Client started.");
  63.                     while(true)
  64.                     {
  65.             string msg = Console.ReadLine();
  66.                         chan::InputMessage <-- msg;
  67.                     }
  68.                 }
  69.  
  70.                 PrimaryChannel::Done <-- Signal.Value;
  71.             }
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement