Exemple #1
0
        /// <summary>
        /// 调用远程RPC
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="serviceName"></param>
        /// <param name="method"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public T RemoteCall <T>(string serviceName, string method, params object[] args)
        {
            T t = default(T);

            byte[] abytes = null;

            if (args != null)
            {
                abytes = ParamsSerializeUtil.Serialize(args);
            }

            var data = _consumerMultiplexer.Request(serviceName, method, abytes, _retry);

            if (data != null)
            {
                try
                {
                    t = ParamsSerializeUtil.Deserialize <T>(data);
                }
                catch
                {
                }
            }
            return(t);
        }
Exemple #2
0
        /// <summary>
        /// 调用远程RPC
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="serviceName"></param>
        /// <param name="method"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public T RemoteCall <T>(string serviceName, string method, params object[] args)
        {
            T t = default(T);

            byte[] abytes = null;

            if (args != null)
            {
                abytes = ParamsSerializeUtil.Serialize(args);
            }

            var data = _consumerMultiplexer.Request(serviceName, method, abytes, _retry);

            if (data != null)
            {
                int offset = 0;
                t = (T)ParamsSerializeUtil.Deserialize(typeof(T), data, ref offset);
            }
            return(t);
        }