private bool AddMonServer(IPAddress serverIP) { try { Uri address = new Uri("net.tcp://" + serverIP + ":41993/IMonService/"); NetTcpBinding binding = new NetTcpBinding(SecurityMode.None); binding.MaxReceivedMessageSize = MAX_SIZE_WCF; binding.MaxBufferSize = Convert.ToInt32(MAX_SIZE_WCF); binding.MaxBufferPoolSize = MAX_SIZE_WCF; EndpointAddress monEndpoint = new EndpointAddress(address); ChannelFactory <IMonService> monFactory = new ChannelFactory <IMonService>(binding, monEndpoint); IMonService monServer = monFactory.CreateChannel(); if (monServer.TestConnection()) { MonServer server = new MonServer(monServer); serverObjects.Add(server); AddToListBoxClients(serverIP.ToString()); return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
/// <summary> /// Инициализация /// </summary> public void Initialize() { Uri address = new Uri(string.Format("net.tcp://{0}:41993/IMonService/", _ip.ToString())); NetTcpBinding binding = new NetTcpBinding(SecurityMode.None); binding.SendTimeout = Constants.SendTimeout; binding.ReceiveTimeout = Constants.ReceiveTimeout; binding.OpenTimeout = Constants.OpenTimeout; binding.CloseTimeout = Constants.CloseTimeout; binding.MaxBufferSize = Constants.MaxBufferSize; binding.MaxReceivedMessageSize = Constants.MaxReceivedMessageSize; binding.MaxBufferPoolSize = Constants.MaxBufferPoolSize; EndpointAddress monEndpoint = new EndpointAddress(address); ChannelFactory <IMonService> monFactory = new DuplexChannelFactory <IMonService>(new InstanceContext(this), binding, monEndpoint); _monService = monFactory.CreateChannel(); ((ICommunicationObject)(_monService)).Faulted += OnMonServerFaulted; }
public MonServer(IMonService _monService) { monService = _monService; }