Beispiel #1
0
        static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                if (args[0] == "producer")
                {
                    // Create a new space repository, and add a new gate to it.
                    // The gate is using CONN, meaning the connection is NOT persistent.
                    SpaceRepository repository = new SpaceRepository();
                    repository.AddGate("tcp://127.0.0.1:123?CONN");

                    // Add a new fifo based space
                    repository.AddSpace("fridge", new SequentialSpace());

                    // Create a new agent, and let the agent use the local tuple space instead of a networked remotespace.
                    AgentBase alice = new Producer("Alice", repository.GetSpace("fridge"));
                    alice.Start();
                    return;
                }
                else if (args[0] == "consumer")
                {
                    // The consumers use a remote space to access the space repository.
                    ISpace           remotespace = new RemoteSpace("tcp://127.0.0.1:123/fridge?CONN");
                    List <AgentBase> agents      = new List <AgentBase>();
                    agents.Add(new FoodConsumer("Bob", remotespace));
                    agents.Add(new FoodConsumer("Charlie", remotespace));
                    agents.Add(new DrugConsumer("Dave", remotespace));
                    agents.ForEach(a => a.Start());
                    Console.Read();
                    return;
                }
            }
            Console.WriteLine("Please specify [producer|consumer]");
            Console.Read();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            SpaceRepository repository = new SpaceRepository();

            repository.AddGate("tcp://127.0.0.1:123?KEEP");
            repository.AddSpace("lifeforms", new SequentialSpace(new EntityFactory()));
            TerminalInfo.Initialize(80, 24);
            Game lifeforms = new Game(repository.GetSpace("lifeforms"));

            lifeforms.Run();
            Console.ReadKey();
            lifeforms.Stop();
        }
Beispiel #3
0
 public JObject GetSpace(string houseid, string spaceid)                        // HTTP GET - gets devices in the space
 {
     return(spaceRepository.GetSpace(houseid, spaceid));
 }