コード例 #1
0
ファイル: RpcStream.cs プロジェクト: urmnur/XNetCore
 /// <summary>
 /// 远程服务调用
 /// </summary>
 /// <param name="service"></param>
 /// <param name="request"></param>
 /// <param name="action"></param>
 /// <returns></returns>
 public void ExcuteService(ClientRegistData service, Channel channel, ServiceRequest request, Delegate action)
 {
     Task.Run(() =>
     {
         try
         {
             doExcuteService(service, channel, request, action).Wait();
         }
         catch (Exception ex)
         {
         }
     });
 }
コード例 #2
0
ファイル: RpcServiceStore.cs プロジェクト: urmnur/XNetCore
        public void RegisterService(RegistData data)
        {
            if (data == null || string.IsNullOrWhiteSpace(data.ServiceInfc))
            {
                return;
            }
            if (this.GetServiceByIntfc(data.ServiceInfc, data.ServiceMethod) != null)
            {
                return;
            }
            var value = new ClientRegistData(data);

            servicestore.TryAdd(Guid.NewGuid().ToString(), value);
        }
コード例 #3
0
ファイル: RpcStream.cs プロジェクト: urmnur/XNetCore
        private async Task doExcuteService(ClientRegistData service, Channel channel, ServiceRequest request, Delegate action)
        {
            var handler    = new ServiceHandlerHelper(service);
            var rpcChannel = channel;

            if (rpcChannel == null)
            {
                rpcChannel = service.ServerChannel;
            }
            var client = new RpcServiceGreeter_Client.RpcServiceGreeterClient(rpcChannel);

            request = new RequestHelper().GetServiceRequest(service, request);
            request = handler.ClientRequest(request);
            await doExcuteService(request, action, client);
        }
コード例 #4
0
        /// <summary>
        /// 远程服务调用
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        private ServiceResponse doExcuteService(ClientRegistData service, Channel channel, ServiceRequest request)
        {
            var handler    = new ServiceHandlerHelper(service);
            var rpcChannel = channel;

            if (rpcChannel == null)
            {
                rpcChannel = service.ServerChannel;
            }
            var client = new RpcServiceGreeter_Client.RpcServiceGreeterClient(rpcChannel);

            request = new RequestHelper().GetServiceRequest(service, request);
            request = handler.ClientRequest(request);
            var result = excuteService(service, request, client);

            result = handler.ClientRespons(request, result);
            return(result);
        }
コード例 #5
0
ファイル: RpcInterceptor.cs プロジェクト: urmnur/XNetCore
 private Channel getChannel(ClientRegistData service)
 {
     return(service.CreateChannel(rpcIp, rpcPort));
 }
コード例 #6
0
 private ServiceResponse excuteService(ClientRegistData service, ServiceRequest request, RpcServiceGreeter_Client.RpcServiceGreeterClient client)
 {
     return(rpcExcuteService(request, client));
 }
コード例 #7
0
 public ServiceResponse ExcuteService(ClientRegistData service, Channel channel, ServiceRequest request)
 {
     return(doExcuteService(service, channel, request));
 }