Example #1
0
        private static INTMinerDaemonService CreateService(string clientHost, int clientPort)
        {
            ChannelFactory <INTMinerDaemonService> factory = null;
            INTMinerDaemonService channel = EmptyNTMinerDaemonService.Instance;

            try {
                var baseUri = new Uri($"http://{clientHost}:{clientPort}/Daemon/");
                factory = new ChannelFactory <INTMinerDaemonService>(ChannelFactory.BasicHttpBinding, new EndpointAddress(new Uri(baseUri, typeof(INTMinerDaemonService).Name)));
                //利用通道创建客户端代理
                channel = factory.CreateChannel();
            }
            catch (Exception e) {
                if (factory != null)
                {
                    factory.Abort();
                }
                Global.Logger.Error(e.Message, e);
            }
            return(channel);
        }