Exemplo n.º 1
0
        public void AgentSupplyGpiTest()
        {
            IGpiA retGpiA = null;

            Regulus.Serialization.ISerializer serializer = new Regulus.Serialization.Dynamic.Serializer();
            IProtocol protocol = ProtocolHelper.CreateProtocol(serializer);

            Stream cdClient = new Regulus.Remote.Standalone.Stream();

            Network.IStreamable             peerClient = cdClient;
            PackageWriter <ResponsePackage> writer     = new PackageWriter <ResponsePackage>(serializer);

            writer.Start(new ReverseStream(cdClient));

            Ghost.IAgent agent = new Regulus.Remote.Ghost.Agent(protocol) as Ghost.IAgent;
            agent.QueryNotifier <IGpiA>().Supply += gpi => retGpiA = gpi;
            agent.Start(peerClient);

            writer.ServerToClient(serializer, ServerToClientOpCode.LoadSoul, new Regulus.Remote.PackageLoadSoul()
            {
                EntityId = 1, ReturnType = false, TypeId = 1
            });
            writer.ServerToClient(serializer, ServerToClientOpCode.LoadSoulCompile, new Regulus.Remote.PackageLoadSoulCompile()
            {
                EntityId = 1, TypeId = 1, ReturnId = 0, PassageId = 0
            });
            while (retGpiA == null)
            {
                agent.Update();
            }
            agent.Stop();
            writer.Stop();
            Assert.AreNotEqual(null, retGpiA);
        }
Exemplo n.º 2
0
        private static void _TestService(IBinderProvider entry, ref bool bind, IProtocol protocol)
        {
            bind = false;
            var service = Regulus.Remote.Standalone.Provider.CreateService(protocol, entry);

            Ghost.IAgent agent = new Regulus.Remote.Ghost.Agent(protocol);
            service.Join(agent, null);
            IGpiA retGpiA = null;
            bool  ret     = false;

            agent.QueryNotifier <IGpiA>().Supply += gpi => {
                ret     = true;
                retGpiA = gpi;
            };
            var timer = new Regulus.Utility.TimeCounter();
            var apr   = new Regulus.Utility.AutoPowerRegulator(new Utility.PowerRegulator());

            while (retGpiA == null)
            {
                apr.Operate();
                agent.Update();
                if (timer.Second > 10)
                {
                    throw new System.Exception($"debug agent:{agent.Active} bind:{bind} ");
                }
            }

            service.Leave(agent);
            service.Dispose();

            Assert.AreNotEqual(null, retGpiA);
            Assert.AreEqual(true, bind);
            Assert.AreEqual(true, ret);
        }
Exemplo n.º 3
0
        public static Regulus.Remote.IAgent CreateRudp(System.Reflection.Assembly protocol_assembly)
        {
            var protocol = Regulus.Remote.Protocol.ProtocolProvider.Create(protocol_assembly);
            var client   = new Regulus.Network.Rudp.ConnectProvider(new Regulus.Network.Rudp.UdpSocket());
            var agent    = new Regulus.Remote.Ghost.Agent(protocol, client);

            return(agent);
        }
Exemplo n.º 4
0
        public static Regulus.Remote.IAgent CreateTcp(params System.Type[] types)
        {
            var client = new  Regulus.Network.Tcp.ConnectProvider();

            var ab          = new Regulus.Remote.Protocol.AssemblyBuilder(types);
            var protocolAsm = ab.Create();
            var protocol    = Regulus.Remote.Protocol.ProtocolProvider.Create(protocolAsm);
            var agent       = new Regulus.Remote.Ghost.Agent(protocol, client);

            return(agent);
        }