public TRemoteService Service <TRemoteService>() { if (proxies.TryGetValue(typeof(TRemoteService), out object ipcProxy)) { return((TRemoteService)ipcProxy); } if (ipcClientChannel == null) { ipcClientChannel = new IpcClientChannel(); ChannelServices.RegisterChannel(ipcClientChannel, true); } string ipcServiceName = ApiIpcCommon.GetServiceName <TRemoteService>(serverId); string ipcUrl = $"ipc://{serverId}/{ipcServiceName}"; Log.Debug($"Calling: {ipcUrl}"); // Get proxy instance of rpc service instance published by server in PublishService() ipcProxy = RemotingServices.Connect(typeof(TRemoteService), ipcUrl); proxies[typeof(TRemoteService)] = ipcProxy; if (ipcProxy == null) { throw new Exception($"Failed to create IPC proxy for {typeof(TRemoteService).FullName}"); } return((TRemoteService)ipcProxy); }
public async Task PublishServiceAsync <TRemoteService>(IApiIpcService ipcService) { if (channelMutex == null) { await CreateServerAsync(); } // Publish the ipc service receiving the data string ipcServiceName = ApiIpcCommon.GetServiceName <TRemoteService>(serverId); RemotingServices.Marshal(ipcService as ApiIpcService, ipcServiceName); Log.Debug($"Published: {ipcServiceName}"); }
public bool TryPublishService(Type interfaceType, IApiIpcService ipcService) { if (channelMutex == null) { if (!TryCreateServer()) { return(false); } } // Publish the ipc service receiving the data string ipcServiceName = ApiIpcCommon.GetServiceName(interfaceType, serverId); RemotingServices.Marshal(ipcService as ApiIpcService, ipcServiceName); Log.Debug($"Published: {ipcServiceName}"); return(true); }