Exemplo n.º 1
0
 public RpcProxyNexus(IRpcClientChannel channel, BaseUri uri, string serviceRole)
 {
     _channel = channel;
     _serverUri = uri;
     _version = RpcProtocolVersion.V4;
     _serviceRole = serviceRole;
 }
Exemplo n.º 2
0
 public static void RegisterClientChannel(IRpcClientChannel channel)
 {
     if (!_channels.ContainsKey(channel.Protocol))
     {
         _channels.Add(channel.Protocol, channel);
     }
 }
Exemplo n.º 3
0
        public async Task EventHandlersWithMultipleClientsWork(ChannelType type)
        {
            bool eventHandlerCalled  = false;
            bool eventHandler2Called = false;
            var  o     = new TestObject();
            var  proxy = await Init <ITestObject>(o, type);


            var client2 = _clientChannel = await CreateClient(type);

            await client2.ConnectAsync();

            var proxy2 = await client2.GetServerObjectAsync <ITestObject>();

            proxy.TestEvent += (s, e) =>
            {
                eventHandlerCalled = true;
                Assert.AreEqual("test", e.Data);
                // try to call back
                Assert.AreEqual("data", proxy.Reflect("data"));
            };


            proxy2.TestEvent += (s, e) =>
            {
                eventHandler2Called = true;
            };

            o.InvokeTestEvent();

            Assert.IsTrue(eventHandlerCalled);
            Assert.IsTrue(eventHandler2Called);
        }
Exemplo n.º 4
0
        private async Task <T> Init <T>(T instance, ChannelType type, IRpcSerializer serializer = null,
                                        TokenImpersonationLevel tokenImpersonationLevel         = TokenImpersonationLevel.None) where T : class
        {
            _serverChannel = await CreateServer(instance, type, serializer, tokenImpersonationLevel);

            switch (type)
            {
            case ChannelType.Tcp:
            {
                var client = _clientChannel = await CreateClient(type, serializer);

                return(await client.GetServerObjectAsync <T>());
            }

            case ChannelType.NamedPipe:
            {
                var client = _clientChannel = await CreateClient(type, serializer, tokenImpersonationLevel);

                return(await client.GetServerObjectAsync <T>());
            }

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 5
0
 public void TestCleanup()
 {
     (_serverChannel as IDisposable)?.Dispose();
     (_clientChannel as IDisposable)?.Dispose();
     _serverChannel = null;
     _clientChannel = null;
 }
Exemplo n.º 6
0
 public RpcProxyNexus(IRpcClientChannel channel, BaseUri uri, string serviceRole)
 {
     _channel     = channel;
     _serverUri   = uri;
     _version     = RpcProtocolVersion.V4;
     _serviceRole = serviceRole;
 }