Пример #1
0
 public RpcBindV4_BehaviorTest(string protocolType)
 {
     if(protocolType == "TCP")
         _conn = RpcClient.FromTcp(Env.PortMapper);
     else
         _conn = RpcClient.FromUdp(Env.PortMapper);
 }
Пример #2
0
 public void init()
 {
     try
     {
         IRpcFactory rpcFactory = new RpcFactory();
         RpcObj = rpcFactory.CreateClient<ILeiloeiro>();
         TcpMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();
         IDuplexOutputChannel anOutputChannel = aMessaging.CreateDuplexOutputChannel("tcp://" + IP + ":" + Porta + "/");//ip local e porta do servidor
         RpcObj.AttachDuplexOutputChannel(anOutputChannel);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro: É necessario iniciar o servidor - " + ex.Message);
     }
 }
Пример #3
0
        private IRpcClient<ILeiloeiro> myRpcClient; //declara o Rpc client

        #endregion Fields

        #region Constructors

        public Form1()
        {
            InitializeComponent();
            tbIP.Text = "127.0.0.1";
            tbPorta.Text = "38445";

            IRpcFactory anRpcFactory = new RpcFactory();
            myRpcClient = anRpcFactory.CreateClient<ILeiloeiro>();

            txtCliente.Enabled = false;
            txtCod.Enabled = false;
            txtValor.Enabled = false;
            SumButton.Enabled = false;
            button1.Enabled = false;
            ResultLabel.Text = "";
            label5.Text = "";
        }
Пример #4
0
 public static T GetService <T>(this IRpcClient rpcClient) where T : class
 {
     return(rpcClient.GetService <T>(null, rpcClient.DefaultTimeout));
 }
Пример #5
0
 /// <summary>
 /// RPCBIND Version 4
 ///
 /// RPCBIND is contacted by way of an assigned address specific to the transport being used.
 /// For TCP/IP and UDP/IP, for example, it is port number 111. Each transport has such an assigned, well-known address.
 /// http://tools.ietf.org/html/rfc1833#section-2.2.1
 /// </summary>
 /// <param name="conn">instance of connector</param>
 /// <param name="token">cancellation token</param>
 /// <param name="attachedToParent">attache created task to parent task</param>
 public RpcBindV4(IRpcClient conn, CancellationToken token, bool attachedToParent)
     : base(conn, token, attachedToParent)
 {
 }
 public XbmcServerClient(IRpcClient client)
 {
     _client = client;
 }
Пример #7
0
 /// <summary>
 /// RPCBIND Version 3
 ///
 /// RPCBIND is contacted by way of an assigned address specific to the transport being used.
 /// For TCP/IP and UDP/IP, for example, it is port number 111. Each transport has such an assigned, well-known address.
 /// http://tools.ietf.org/html/rfc1833#section-2.2.1
 /// </summary>
 public static RpcBindV3 RpcBindV3(this IRpcClient conn, CancellationToken token, bool attachedToParent = false)
 {
     return(new RpcBindV3(conn, token, attachedToParent));
 }
Пример #8
0
 /// <summary>
 /// RPCBIND Version 4
 ///
 /// RPCBIND is contacted by way of an assigned address specific to the transport being used.
 /// For TCP/IP and UDP/IP, for example, it is port number 111. Each transport has such an assigned, well-known address.
 /// http://tools.ietf.org/html/rfc1833#section-2.2.1
 /// </summary>
 public static RpcBindV4 RpcBindV4(this IRpcClient conn, bool attachedToParent = false)
 {
     return(new RpcBindV4(conn, CancellationToken.None, attachedToParent));
 }
Пример #9
0
 public RpcClientComponentContainer(IRpcClient client, RpcClientComponentOverrides overrides)
 {
     this.client    = client;
     this.overrides = overrides;
 }
Пример #10
0
 /// <summary>
 /// The portmapper program currently supports two protocols (UDP and TCP).  The portmapper is contacted by talking to it on assigned port
 /// number 111 (SUNRPC) on either of these protocols.
 /// http://tools.ietf.org/html/rfc1833#section-3.2
 /// </summary>
 public static PortMapper PortMapper(this IRpcClient conn, bool attachedToParent = false)
 {
     return(new PortMapper(conn, CancellationToken.None, attachedToParent));
 }
 public RpcClientComponentContainer(IRpcClient client, RpcClientComponentOverrides overrides)
 {
     this.client = client;
     this.overrides = overrides;
 }
Пример #12
0
        /// <summary>
        /// 调用
        /// </summary>
        /// <param name="method">方法</param>
        /// <param name="message">消息</param>
        /// <returns>返回数据</returns>
        public object Call(MethodInfo method, object message)
        {
            var assemblyName = method.DeclaringType.Assembly.GetName().Name;
            var configInfo   = rabbitConfigReader.Reader();

            if (configInfo == null)
            {
                throw new Exception("找不到RabbitConfig配置信息");
            }

            RpcClientAssemblyWrapInfo rpcClientAssemblyWrap;
            var messQueueInfo = GetMessageQueueByAssemblyName(configInfo, assemblyName, out rpcClientAssemblyWrap);

            if (rpcClientAssemblyWrap == null)
            {
                throw new Exception($"找不到程序集[{assemblyName}]的RPC客户端配置信息");
            }

            var byteSeri = GetByteSerialization(rpcClientAssemblyWrap.RpcClientAssembly.DataType);
            var byteData = byteSeri.Serialize(message);

            IRpcClient rpcClient = null;

            if (dicVirtualPathMapRpcClient.ContainsKey(rpcClientAssemblyWrap.RabbitVirtualPath.VirtualPath))
            {
                rpcClient = dicVirtualPathMapRpcClient[rpcClientAssemblyWrap.RabbitVirtualPath.VirtualPath];
            }
            else
            {
                lock (syncDicVirtualPathMapRpcClient)
                {
                    IMessageQueueConnection conn = null;
                    // 如果连接配置信息不全,则找默认的连接对象
                    if (string.IsNullOrWhiteSpace(rpcClientAssemblyWrap.RabbitVirtualPath.ConnectionString) && string.IsNullOrWhiteSpace(rpcClientAssemblyWrap.RabbitVirtualPath.ConnectionStringAppConfigName))
                    {
                        conn = SingleConnectionTool.CreateConnection();
                    }
                    else
                    {
                        conn = connectionFactoy.CreateAndOpen(new ConnectionWrapInfo()
                        {
                            ConnectionString = rpcClientAssemblyWrap.RabbitVirtualPath.ConnectionString,
                            ConnectionStringAppConfigName = rpcClientAssemblyWrap.RabbitVirtualPath.ConnectionStringAppConfigName
                        });
                    }
                    connections.Add(conn);

                    rpcClient = conn.CreateRpcClient(messQueueInfo);
                    try
                    {
                        dicVirtualPathMapRpcClient.Add(rpcClientAssemblyWrap.RabbitVirtualPath.VirtualPath, rpcClient);
                    }
                    catch (ArgumentException) { }
                }
            }

            var reData = rpcClient.Call(byteData);

            // 如果返回值是空或者类型是void,则直接返回null
            if (reData.IsNullOrLength0() || method.ReturnType.IsTypeVoid())
            {
                return(null);
            }
            else
            {
                Type targetType = null;

                // 判断返回类型是否Task
                if (method.ReturnType.IsTypeNotGenericityTask())
                {
                    return(null);
                }
                else if (method.ReturnType.IsTypeGenericityTask())
                {
                    targetType = method.ReturnType.GetProperty("Result").PropertyType;
                }
                else
                {
                    targetType = method.ReturnType;
                }

                return(byteSeri.Deserialize(reData, targetType));
            }
        }
 public OmvDiskMgmtClient(IRpcClient client) : base(client)
 {
     ServiceName = "DiskMgmt";
 }
        public void Setup()
        {
            Rabbit.Initialize();

            _rpcClient =
                new RpcClient(
                    new MessageFormatter(new Utf8MessageSerializer(null), new JsonMessageStringifier(null), null),
                    ComponentLocator.Current.Get<IModel>(),
                    null);

            var model = ComponentLocator.Current.Get<IModel>();
            model.QueueDeclare("Rpc_Test_Queue_2_2_2", false, false, true, null);
            model.ExchangeDeclare("Rcp_Test_Exchange_2_2_2", "direct", false);
            model.QueueBind("Rpc_Test_Queue_2_2_2", "Rcp_Test_Exchange_2_2_2", "abc");

            _serverThread = new Thread(StartRpcServer);
            _serverThread.Start();
        }
Пример #15
0
 public CallContextTestClient(IRpcClient <AmpMessage> client) : base(client)
 {
 }
Пример #16
0
 public AmpCallInvoker(IRpcClient <AmpMessage> client) : base(client)
 {
 }
Пример #17
0
 public AuthServiceClient(IRpcClient <AmpMessage> client) : base(client)
 {
 }
Пример #18
0
 public static T GetService <T>(this IRpcClient rpcClient, string scope) where T : class
 {
     return(rpcClient.GetService <T>(scope, rpcClient.DefaultTimeout));
 }
Пример #19
0
 public OmvLogFileClient(IRpcClient client) : base(client)
 {
     ServiceName = "LogFile";
 }
Пример #20
0
 public DirectCardPaymentService(IRpcClient rpcClient)
 {
     this.rpcClient = rpcClient;
 }
 public OmvServicesClient(IRpcClient client) : base(client)
 {
     ServiceName = "Services";
 }
 public OmvConfigClient(IRpcClient client) : base(client)
 {
     ServiceName = "Config";
 }
Пример #23
0
 public StatisticServiceClient(IRpcClient <AmpMessage> client) : base(client)
 {
 }