Package org.ros.internal.node.topic
Class DefaultSubscriber<T>
java.lang.Object
org.ros.internal.node.topic.DefaultTopicParticipant
org.ros.internal.node.topic.DefaultSubscriber<T>
- All Implemented Interfaces:
TopicParticipant,Subscriber<T>
Default implementation of a
Subscriber.- Author:
- damonkohler@google.com (Damon Kohler)
-
Field Summary
Fields inherited from interface org.ros.node.topic.Subscriber
TOPIC_MESSAGE_TYPE_WILDCARD -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMessageListener(org.ros.message.MessageListener<T> messageListener) Adds aMessageListenerwith a limit of 1.voidaddMessageListener(org.ros.message.MessageListener<T> messageListener, int limit) Adds aMessageListenerto be called when new messages are received.voidaddPublisher(PublisherIdentifier publisherIdentifier, InetSocketAddress address) voidaddSubscriberListener(SubscriberListener<T> listener) Add a new lifecycle listener to the subscriber.booleanstatic <S> DefaultSubscriber<S>newDefault(NodeIdentifier nodeIdentifier, TopicDeclaration description, ScheduledExecutorService executorService, org.ros.message.MessageDeserializer<S> deserializer) voidRemoves all registeredMessageListeners.booleanremoveMessageListener(org.ros.message.MessageListener<T> messageListener) Removes a previously addedMessageListener.voidshutdown()Shuts down and unregisters theSubscriberusing the default timeout forSubscriberListener.onShutdown(Subscriber)callbacks.voidShuts down and unregisters theSubscriber.voidSignal allSubscriberListeners that theSubscriberhas failed to register with the master.voidSignal allSubscriberListeners that theSubscriberhas successfully registered with the master.voidSignal allSubscriberListeners that theSubscriberhas failed to unregister with the master.voidSignal allSubscriberListeners that theSubscriberhas successfully unregistered with the master.voidsignalOnNewPublisher(PublisherIdentifier publisherIdentifier) Signal allSubscriberListeners that a newPublisherhas connected.toString()voidupdatePublishers(Collection<PublisherIdentifier> publisherIdentifiers) Updates the list ofPublishers for the topic that thisSubscriberis interested in.Methods inherited from class org.ros.internal.node.topic.DefaultTopicParticipant
getTopicDeclaration, getTopicDeclarationAsList, getTopicDeclarationHeader, getTopicMessageType, getTopicNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.ros.internal.node.topic.TopicParticipant
getTopicMessageType, getTopicName
-
Method Details
-
newDefault
public static <S> DefaultSubscriber<S> newDefault(NodeIdentifier nodeIdentifier, TopicDeclaration description, ScheduledExecutorService executorService, org.ros.message.MessageDeserializer<S> deserializer) -
toIdentifier
-
toDeclaration
-
getSupportedProtocols
-
getLatchMode
public boolean getLatchMode()- Specified by:
getLatchModein interfaceSubscriber<T>- Returns:
trueif thePublisherof thisSubscriber's topic is latched,falseotherwise
-
addMessageListener
Description copied from interface:SubscriberAdds aMessageListenerto be called when new messages are received.The
MessageListenerwill be executed serially in its own thread. If theMessageListenerprocesses new messages slower than they arrive, new messages will be queued up to the specified limit. Older messages are removed from the buffer when the buffer limit is exceeded.- Specified by:
addMessageListenerin interfaceSubscriber<T>- Parameters:
messageListener- thisMessageListenerwill be called when new messages are receivedlimit- the maximum number of messages to buffer
-
addMessageListener
Description copied from interface:SubscriberAdds aMessageListenerwith a limit of 1.- Specified by:
addMessageListenerin interfaceSubscriber<T>- See Also:
-
removeMessageListener
Description copied from interface:SubscriberRemoves a previously addedMessageListener.- Specified by:
removeMessageListenerin interfaceSubscriber<T>- Parameters:
messageListener-MessageListenerto remove.- Returns:
- True if the listener was removed, false if it wasn't registered before.
-
removeAllMessageListeners
public void removeAllMessageListeners()Description copied from interface:SubscriberRemoves all registeredMessageListeners.- Specified by:
removeAllMessageListenersin interfaceSubscriber<T>
-
addPublisher
-
updatePublishers
Updates the list ofPublishers for the topic that thisSubscriberis interested in.- Parameters:
publisherIdentifiers-CollectionofPublisherIdentifiers for the subscribed topic
-
shutdown
Description copied from interface:SubscriberShuts down and unregisters theSubscriber. using the default timeout Shutdown is delayed by at most the specified timeout to allowSubscriberListener.onShutdown(Subscriber)callbacks to complete.SubscriberListener.onShutdown(Subscriber)callbacks are executed in separate threads.- Specified by:
shutdownin interfaceSubscriber<T>
-
shutdown
public void shutdown()Description copied from interface:SubscriberShuts down and unregisters theSubscriberusing the default timeout forSubscriberListener.onShutdown(Subscriber)callbacks.SubscriberListener.onShutdown(Subscriber)callbacks are executed in separate threads.- Specified by:
shutdownin interfaceSubscriber<T>- See Also:
-
addSubscriberListener
Description copied from interface:SubscriberAdd a new lifecycle listener to the subscriber.- Specified by:
addSubscriberListenerin interfaceSubscriber<T>- Parameters:
listener- The listener to add.
-
signalOnMasterRegistrationSuccess
public void signalOnMasterRegistrationSuccess()Signal allSubscriberListeners that theSubscriberhas successfully registered with the master.Each listener is called in a separate thread.
- Specified by:
signalOnMasterRegistrationSuccessin classDefaultTopicParticipant
-
signalOnMasterRegistrationFailure
public void signalOnMasterRegistrationFailure()Signal allSubscriberListeners that theSubscriberhas failed to register with the master.Each listener is called in a separate thread.
- Specified by:
signalOnMasterRegistrationFailurein classDefaultTopicParticipant
-
signalOnMasterUnregistrationSuccess
public void signalOnMasterUnregistrationSuccess()Signal allSubscriberListeners that theSubscriberhas successfully unregistered with the master.Each listener is called in a separate thread.
- Specified by:
signalOnMasterUnregistrationSuccessin classDefaultTopicParticipant
-
signalOnMasterUnregistrationFailure
public void signalOnMasterUnregistrationFailure()Signal allSubscriberListeners that theSubscriberhas failed to unregister with the master.Each listener is called in a separate thread.
- Specified by:
signalOnMasterUnregistrationFailurein classDefaultTopicParticipant
-
signalOnNewPublisher
Signal allSubscriberListeners that a newPublisherhas connected.Each listener is called in a separate thread.
-
toString
-