Пример #1
0
        private static RpcClientProxy GetProxyInner <T>(ServerUri solvedUri, ResolvableUri contextUri)
        {
            RpcClientInterface intf = RpcClientInterfaceFactory <T> .GetOne();

            if (_channels.Count == 0)
            {
                throw new Exception("You *MUST* Register at least 1 client channel at first");
            }

            RpcClientChannel channel;

            if (!_channels.TryGetValue(solvedUri.Protocol, out channel))
            {
                throw new Exception(string.Format("{0} protocol:'{1}' not found", solvedUri.ToString(), solvedUri.Protocol));
            }

            ResolvableUri r    = contextUri as ResolvableUri;
            string        role = r != null ? r.Service : "";
            RpcConnection conn = GetConnection(solvedUri, role);

            RpcClientProxy proxy = new RpcClientProxy(conn, intf, contextUri);

            proxy.Timeout = channel.Timeout;
            return(proxy);
        }
Пример #2
0
        private static RpcClientProxy GetProxyInner(ServerUri solvedUri, ResolvableUri toUri, string serviceName)
        {
            if (_channels.Count == 0)
            {
                throw new Exception("You *MUST* Register at least 1 client channel at first");
            }

            IRpcClientChannel channel;

            if (!_channels.TryGetValue(solvedUri.Protocol, out channel))
            {
                throw new Exception(string.Format("{0} protocol:'{1}' not found", solvedUri.ToString(), solvedUri.Protocol));
            }

            RpcProxyNexus nexus;

            lock (_syncRoot) {
                if (!_nexuses.TryGetValue(solvedUri, out nexus))
                {
                    ResolvableUri r           = toUri as ResolvableUri;
                    string        serviceRole = r != null ? r.Service : "";
                    nexus = new RpcProxyNexus(channel, solvedUri, serviceRole);
                    _nexuses.Add(solvedUri, nexus);
                }
            }

            RpcClientProxy proxy = new RpcClientProxy(nexus, serviceName, toUri);

            return(proxy);
        }
Пример #3
0
 public RpcClientProxy(RpcClientProxy proxy)
 {
     _proxy = proxy;
 }