protected void InitServerAndClient(string address, int port) { if (_server != null) { _server.Dispose(); _server = null; } _server = new TcpSlaveServer(port, address, ServerConfiguration.Default, new NetworkLocalizer(Thread.CurrentThread.CurrentUICulture.Name)); _client = new Client(""); _client.ConnectTo(_server); }
public Task DisposeAsync() { if (_disposed) { throw new ObjectDisposedException("Node"); } _disposed = true; var tasks = new List <Task>(); tasks.AddRange(_topicContainer.GetPublishers().Select(pub => pub.DisposeAsync())); tasks.AddRange(_topicContainer.GetSubscribers().Select(sub => sub.DisposeAsync())); tasks.AddRange(_serviceProxies.Values.Select(proxy => proxy.DisposeAsync())); tasks.AddRange(_serviceServers.Values.Select(service => service.DisposeAsync())); tasks.AddRange(_parameters.Values.Select(param => param.DisposeAsync())); return(Task.Factory.StartNew(() => { try { Task.WaitAll(tasks.ToArray()); } catch (Exception ex) { _logger.Error("Node Dispose Error", ex); } var handler = Disposing; Disposing = null; if (handler != null) { handler(NodeId); } _slaveServer.Dispose(); })); }
public void Cleanup() { _slaveServer.Dispose(); Ros.Dispose(); }