public bool Connect(ClientCrawlerInfo clientCrawlerInfo) { try { var site = new InstanceContext(this); var binding = new NetTcpBinding(SecurityMode.None); //var address = new EndpointAddress("net.tcp://localhost:22222/chatservice/"); var address = new EndpointAddress("net.tcp://193.124.113.235:22222/chatservice/"); var factory = new DuplexChannelFactory<IRemoteCrawler>(site, binding, address); proxy = factory.CreateChannel(); ((IContextChannel)proxy).OperationTimeout = new TimeSpan(1, 0, 10); clientCrawlerInfo.ClientIdentifier = _singletoneId; proxy.Join(clientCrawlerInfo); return true; } catch (Exception ex) { MessageBox.Show("Error happened" + ex.Message); return false; } }
public static CrawlerConnection ConvertToCrawlerConnection(ClientCrawlerInfo connection) { var result = new CrawlerConnection(); result.CrawlerIP = connection.ServerIP; result.CrawlerName = connection.ClientName; result.Id = connection.ClientIdentifier; return result; }
private void ConnectToServer() { var singleTone = ConnectionSingleton.Instance; var newPerson = new ClientCrawlerInfo { ClientName = ClientName, ServerIP = LocalIpAddress }; var result = singleTone.Connect(newPerson); if (result) CrawlerStatus = "Connected"; }