Пример #1
0
        public override void SetUp()
        {
            // increase timeouts to balance unpredictable agent performance
            myRespectRpcTimeouts           = RpcTimeouts.RespectRpcTimeouts;
            RpcTimeouts.RespectRpcTimeouts = false;
            CFacade = new ReflectionSerializersFacade(allowSave: true);
            SFacade = new ReflectionSerializersFacade(allowSave: true);

            base.SetUp();
            ServerWire.AutoTransmitMode = true;
            ClientWire.AutoTransmitMode = true;
        }
Пример #2
0
        private static void MainLifetime(string[] args, LifetimeDefinition lifetimeDefinition)
        {
            var lifetime = lifetimeDefinition.Lifetime;

            var reflectionSerializers = new ReflectionSerializersFacade();
            var serializers           = new Serializers(reflectionSerializers.Registrar);

            var      scheduler = SingleThreadScheduler.RunOnSeparateThread(lifetime, "Scheduler");
            Protocol protocol;

            SocketWire.Base wire;


            var isServer = args.Length == 0 ? Util.Fork(args) : args[0] == "server";

            if (isServer)
            {
                Console.Title = "Server";
                wire          = new SocketWire.Server(lifetime, scheduler, ourIpEndPoint);
                protocol      = new Protocol("Server", serializers, new Identities(IdKind.Server), scheduler, wire, lifetime);
            }
            else
            {
                Console.Title = "Client";
                wire          = new SocketWire.Client(lifetime, scheduler, ourIpEndPoint);
                protocol      = new Protocol("Client", serializers, new Identities(IdKind.Client), scheduler, wire, lifetime);
            }

            scheduler.Queue(() => RunApplication(isServer, reflectionSerializers, lifetime, protocol));

            wire.Connected.Change.Advise(lifetime, value =>
            {
                if (value)
                {
                    Console.Title += ": connected";
                }
                else
                {
                    lifetimeDefinition.Terminate();
                }
            });

            while (lifetime.IsAlive)
            {
                if (Console.KeyAvailable && OnChar != null)
                {
                    scheduler.Queue(() => OnChar?.Invoke(Console.ReadKey(true).KeyChar));
                }

                Thread.Sleep(100);
            }
        }
Пример #3
0
    private static void RunApplication(bool isServer, ReflectionSerializersFacade facade, Lifetime lifetime, Protocol protocol)
    {
      IRootExt root;
      if (isServer)
      {
        root = facade.ActivateProxy<IRootExt>(lifetime, protocol);
      }
      else
      {
        root = facade.InitBind(new RootExt(), lifetime, protocol);
      }
      (root as RdExtReflectionBindableBase).Connected.Advise(lifetime, v => Console.WriteLine("RootExt connected: " + v));

      root.OnChar.Advise(lifetime, Console.Write);
      OnChar += c => root.OnChar.Fire(c);
    }
Пример #4
0
        private static void RunApplication(bool isServer, ReflectionSerializersFacade facade, Lifetime lifetime, Protocol protocol)
        {
            IRootExt root;

            if (isServer)
            {
                root = facade.ActivateProxy <IRootExt>(lifetime, protocol);
            }
            else
            {
                root = facade.InitBind(new RootExt(), lifetime, protocol);
            }

            root.OnChar.Advise(lifetime, Console.Write);
            OnChar += c => root.Greet(c.ToString());
        }