Esempio n. 1
0
 public RPrint()
     : base()
 {
     DirectoryActor.GetDirectory().Register(this, "RPrint");
     HostDirectoryActor.Register(this);
     Become(new Behavior <string>(DoRPrint));
 }
 public void FindTest()
 {
     TestLauncherActor.Test(() =>
     {
         var dirtest = new DirectoryTestActor();
         DirectoryActor.GetDirectory().Register(dirtest, dirtest.Tag.Key());
     });
 }
 public void DirectoryActorTest()
 {
     fLauncher.SendAction(() =>
     {
         IActor act = new DirectoryTestActor();
         act.SendMessage(fLauncher, DirectoryActor.GetDirectory(), "Directory");
     });
     Assert.IsTrue(fLauncher.Wait(100000).Result);
 }
 public void RegisterTest()
 {
     TestLauncherActor.Test(() =>
     {
         var act = new DirectoryTestActor();
         DirectoryActor.GetDirectory().Register(act, act.Tag.Key());
         act.SendMessage(fLauncher, act, act.Tag.Key());
     });
 }
 public void DiscoTest()
 {
     TestLauncherActor.Test(() =>
     {
         ActorServer.Start("localhost", 80, null);
         var act = new DiscoTestActor(fLauncher);
         DirectoryActor.GetDirectory().Disco(act);
     }
                            );
 }
        private void DoIt(IActor caller, IActor lookup, string name)
        {
            DirectoryActor.GetDirectory().Find(this, name);
            var task = Receive(ask => { return(ask is IMessageParam <DirectoryActor.DirectoryRequest, IActor>); });

            if ((task.Result as IMessageParam <DirectoryActor.DirectoryRequest, IActor>).Item2 == lookup)
            {
                caller.SendMessage(true);
            }
        }
 public void DiscoTest()
 {
     TestLauncherActor.Test(() =>
     {
         ActorServer.Start(ActorConfigManager.CastForTest());
         var act = new DiscoTestActor(fLauncher);
         DirectoryActor.GetDirectory().Disco(act);
     }
                            );
 }
 public void FindTest()
 {
     fLauncher.SendAction(() =>
     {
         var dirtest = new DirectoryTestActor();
         DirectoryActor.GetDirectory().Register(dirtest, dirtest.Tag.Key());
         fLauncher.Finish();
     });
     Assert.IsTrue(fLauncher.Wait());
 }
 public void RegisterTest()
 {
     fLauncher.SendAction(() =>
     {
         var act = new DirectoryTestActor();
         DirectoryActor.GetDirectory().Register(act, act.Tag.Key());
         act.SendMessage(fLauncher, act, act.Tag.Key());
         fLauncher.Finish();
     });
     Assert.IsTrue(fLauncher.Wait());
 }
Esempio n. 10
0
 public void DirectoryFindActorTest()
 {
     TestLauncherActor.Test(() =>
     {
         var dirtest = new BaseActor();
         DirectoryActor.GetDirectory().Register(dirtest, dirtest.Tag.Key());
         var result = DirectoryActor.GetDirectory().FindActor(dirtest.Tag.Key()).Result(5000);
         Assert.IsTrue(result.Item1 == DirectoryActor.DirectoryRequest.Find);
         Assert.IsNotNull(result.Item2);
         Assert.AreEqual(dirtest, result.Item2);
     }, -1);
 }
 public void DiscoTest()
 {
     ActorServer.Start("localhost", 80, null);
     fLauncher.SendAction(() =>
     {
         var act = new DiscoTestActor(fLauncher);
         DirectoryActor.GetDirectory().Disco(act);
         fLauncher.Finish();
     }
                          );
     Assert.IsTrue(fLauncher.Wait());
 }
Esempio n. 12
0
        public PersistentActor(IPersistentService <T> service, string actorName) : base()
        {
            var act = DirectoryActor.GetDirectory().GetActorByName(actorName);

            if (act == null)
            {
                DirectoryActor.GetDirectory().Register(this, actorName);
            }
            Become(new PersistentLoadBehavior <T>(service));
            AddBehavior(new PersistentWriteBehavior <T>(service));
            AddBehavior(new Behavior <IEventSource <T> >(Transact));
            AddBehavior(new Behavior <PersistentCommand, IActor>(
                            (c, a) => c == PersistentCommand.GetCurrent,
                            (c, a) => a.SendMessage(fCurrentState)));
        }
Esempio n. 13
0
        private void Behavior(Chunk msg)
        {
            fChunkList.Add(msg);
            var lastMsg = fChunkList.Where(t => t.last).FirstOrDefault();

            if ((lastMsg != null) && (fChunkList.Count - 1 == lastMsg.chunkPart))
            {
                // send complete to sender
                msg.sender.SendMessage("Download complete");
                // try to do something with this assembly
                MemoryStream ms   = new MemoryStream();
                Assembly     asm2 = null;
                try
                {
                    foreach (var item in fChunkList.OrderBy(t => t.chunkPart))
                    {
                        ms.Write(item.data, 0, item.data.Length);
                    }

                    asm2 = Assembly.Load(ms.ToArray());
                }
                finally
                {
                    ms.Dispose();
                }
                Debug.Assert(Assembly.GetExecutingAssembly() != asm2);
                Console.WriteLine(asm2.GetName());
                Console.WriteLine("Location" + asm2.Location);

                IActor asmobj = asm2.CreateInstance("Actor.Plugin.actPlugin") as IActor;

                Debug.Assert(asmobj != null);

                // register in directory

                DirectoryActor.GetDirectory().Register(asmobj, "plugin");

                asmobj.SendMessage("Hello");
                SendByName <string> .Send("by name", "plugin");
            }
        }
Esempio n. 14
0
 public void StatTest()
 {
     Assert.IsTrue(DirectoryActor.GetDirectory().Stat().StartsWith("Directory entries "));
 }
Esempio n. 15
0
 public void GetDirectoryTest()
 {
     Assert.IsTrue(DirectoryActor.GetDirectory() is DirectoryActor);
 }
Esempio n. 16
0
 public void StatTest()
 {
     Assert.IsTrue(DirectoryActor.GetDirectory().Stat().StartsWith("Directory entries ", System.StringComparison.InvariantCulture));
 }