/// <summary> /// Retrieve a list of topics that this node subscribes to /// </summary> /// <param name="callerId"> ROS caller ID. </param> /// <returns> /// [0] = int: code <br/> /// [1] = str: status message <br/> /// [2] = topicList is a list of topics this node subscribes to and is of the form [ [topic1, topicType1]...[topicN, topicTypeN]]] /// </returns> public object[] GetSubscriptions(string callerId) { _logger.Debug(m => m("GetSubscriptions(callerId={0})", callerId)); return(new object[] { StatusCode.Success, "Success", _topicContainer.GetSubscribers().Select(x => new object[] { x.TopicName, x.MessageType }).ToArray() }); }
public void RemoveSubscriber_Success() { var container = new TopicContainer(); ISubscriber sub; container.HasSubscriber("sub1").Is(false); container.GetSubscribers().Count.Is(0); container.AddSubscriber(new Subscriber <std_msgs.String>("sub1", "test")).Is(true); container.HasSubscriber("sub1").Is(true); container.GetSubscribers().Count.Is(1); container.GetSubscriber("sub1", out sub).Is(true); container.RemoveSubscriber("sub1").Is(true); container.GetSubscriber("sub1", out sub).Is(false); container.RemoveSubscriber("sub1").Is(false); }
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(); })); }