Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Microsoft.Axum;
- using System.Concurrency.Messaging;
- using System.ServiceModel;
- namespace SimpleDistro
- {
- channel Simple
- {
- input string InputMessage;
- output string OutputMessage;
- }
- domain ServiceDomain
- {
- public agent ServiceAgent : channel Simple
- {
- public ServiceAgent ()
- {
- // Do something useful.
- string message = receive(PrimaryChannel::InputMessage);
- PrimaryChannel::OutputMessage <-- message;
- }
- }
- }
- public domain Program
- {
- agent Server : channel Microsoft.Axum.Application
- {
- public Server()
- {
- String [] args = receive(PrimaryChannel::CommandLine);
- var auctionAddr = "net.tcp://localhost:4711/simpleService1";
- bool isServer = (args.Length > 0 && args[0] == "server");
- if(isServer)
- {
- var hst = new TcpServiceHost();
- //var hst = new WcfServiceHost(new NetTcpBinding(SecurityMode.None, false));
- hst.Host<ServiceDomain.ServiceAgent>(auctionAddr, new ServiceDomain());
- }
- var prov = new TcpCommunicationProvider();
- //var prov = new WcfCommunicationProvider(new NetTcpBinding(SecurityMode.None, false));
- var chan = prov.Connect<Simple>(auctionAddr);
- if(isServer)
- {
- Console.WriteLine("Server started.");
- while(true)
- {
- var msg = receive(chan::OutputMessage); // <------- NEVER RECEIVING!
- Console.WriteLine(msg);
- }
- }
- else
- {
- Console.WriteLine("Client started.");
- while(true)
- {
- string msg = Console.ReadLine();
- chan::InputMessage <-- msg;
- }
- }
- PrimaryChannel::Done <-- Signal.Value;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement