/// <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) { } }); }
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); }
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); }
/// <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); }
private Channel getChannel(ClientRegistData service) { return(service.CreateChannel(rpcIp, rpcPort)); }
private ServiceResponse excuteService(ClientRegistData service, ServiceRequest request, RpcServiceGreeter_Client.RpcServiceGreeterClient client) { return(rpcExcuteService(request, client)); }
public ServiceResponse ExcuteService(ClientRegistData service, Channel channel, ServiceRequest request) { return(doExcuteService(service, channel, request)); }