Exemplo n.º 1
0
        public static void CreateServerAndClient <T, I>(T impl, out IActorServerProxy server, out IActorClientProxy <I> client)
        {
            server = ActorServerProxy.Create("tcp://*:0", impl);
            int port = server.BindEndPoint.Port;

            client = ActorClientProxy.CreateProxy <I>("tcp://localhost:" + port).Result;
        }
Exemplo n.º 2
0
        /// <param name="bindEndPoint">tcp://*:4632</param>
        public void Start(string bindEndPoint)
        {
            if (_actorServer != null)
                throw new InvalidOperationException("Already started");

            _actorServer = ActorServerProxy.Create<MemCacheActor>(bindEndPoint);
        }
Exemplo n.º 3
0
        public static void CreateServerAndClientProxy <T, I>(out IActorServerProxy server, out IActorClientProxy <I> client)
            where T : new()
        {
            server = ActorServerProxy.Create <T>("tcp://*:0");
            int port = server.BindEndPoint.Port;

            client = ActorClientProxy.CreateProxy <I>("tcp://localhost:" + port).Result;
        }
Exemplo n.º 4
0
        public async void Client_should_be_disconnected_after_over_30_seconds_after_last_ping()
        {
            var disconnected = new ManualResetEventSlim();
            server = ActorServerProxy.Create<TestActor>("tcp://*:0");
            int port = server.BindEndPoint.Port;

            client = new FramedClient(new SocketClient());
            await client.Connect("tcp://localhost:" + port);

            client.Received.Subscribe(x => Console.WriteLine("Received " + x.Count + " bytes. " +
                "Header: " + BitConverter.ToInt32(x.Array, x.Offset) + " " +
                "Id: " + BitConverter.ToInt32(x.Array, x.Offset + 4)));
            client.Disconnected.Subscribe(_ => disconnected.Set());

            SendHandshake();
            SendPing();

            Thread.Sleep(40000);
            Assert.False(disconnected.IsSet);
            disconnected.Wait(40000);
            Assert.True(disconnected.IsSet);
        }
Exemplo n.º 5
0
        public async void Client_should_be_disconnected_after_over_30_seconds_after_last_ping()
        {
            var disconnected = new ManualResetEventSlim();

            server = ActorServerProxy.Create <TestActor>("tcp://*:0");
            int port = server.BindEndPoint.Port;

            client = new FramedClient(new SocketClient());
            await client.Connect("tcp://localhost:" + port);

            client.Received.Subscribe(x => Console.WriteLine("Received " + x.Count + " bytes. " +
                                                             "Header: " + BitConverter.ToInt32(x.Array, x.Offset) + " " +
                                                             "Id: " + BitConverter.ToInt32(x.Array, x.Offset + 4)));
            client.Disconnected.Subscribe(_ => disconnected.Set());

            SendHandshake();
            SendPing();

            Thread.Sleep(40000);
            Assert.False(disconnected.IsSet);
            disconnected.Wait(40000);
            Assert.True(disconnected.IsSet);
        }
Exemplo n.º 6
0
 public static void CreateServerAndClient <T, I>(out IActorServerProxy server, out I client)
     where T : new()
 {
     CreateServerAndClient <T, I>(ActorServerProxyOptions.Default, out server, out client);
 }