public class DefaultSubscriber<T> extends DefaultTopicParticipant implements Subscriber<T>
Subscriber
.TOPIC_MESSAGE_TYPE_WILDCARD
Modifier and Type | Method and Description |
---|---|
void |
addMessageListener(org.ros.message.MessageListener<T> messageListener)
Adds a
MessageListener with a limit of 1. |
void |
addMessageListener(org.ros.message.MessageListener<T> messageListener,
int limit)
Adds a
MessageListener to be called when new messages are received. |
void |
addPublisher(PublisherIdentifier publisherIdentifier,
java.net.InetSocketAddress address) |
void |
addSubscriberListener(SubscriberListener<T> listener)
Add a new lifecycle listener to the subscriber.
|
boolean |
getLatchMode() |
java.util.Collection<java.lang.String> |
getSupportedProtocols() |
static <S> DefaultSubscriber<S> |
newDefault(NodeIdentifier nodeIdentifier,
TopicDeclaration description,
java.util.concurrent.ScheduledExecutorService executorService,
org.ros.message.MessageDeserializer<S> deserializer) |
void |
shutdown()
Shuts down and unregisters the
Subscriber using the default timeout
for SubscriberListener.onShutdown(Subscriber) callbacks. |
void |
shutdown(long timeout,
java.util.concurrent.TimeUnit unit)
Shuts down and unregisters the
Subscriber . |
void |
signalOnMasterRegistrationFailure()
Signal all
SubscriberListener s that the Subscriber has
failed to register with the master. |
void |
signalOnMasterRegistrationSuccess()
Signal all
SubscriberListener s that the Subscriber has
successfully registered with the master. |
void |
signalOnMasterUnregistrationFailure()
Signal all
SubscriberListener s that the Subscriber has
failed to unregister with the master. |
void |
signalOnMasterUnregistrationSuccess()
Signal all
SubscriberListener s that the Subscriber has
successfully unregistered with the master. |
void |
signalOnNewPublisher(PublisherIdentifier publisherIdentifier)
Signal all
SubscriberListener s that a new Publisher has
connected. |
SubscriberDeclaration |
toDeclaration() |
SubscriberIdentifier |
toIdentifier() |
java.lang.String |
toString() |
void |
updatePublishers(java.util.Collection<PublisherIdentifier> publisherIdentifiers)
Updates the list of
Publisher s for the topic that this
Subscriber is interested in. |
getTopicDeclaration, getTopicDeclarationAsList, getTopicDeclarationHeader, getTopicMessageType, getTopicName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getTopicMessageType, getTopicName
public static <S> DefaultSubscriber<S> newDefault(NodeIdentifier nodeIdentifier, TopicDeclaration description, java.util.concurrent.ScheduledExecutorService executorService, org.ros.message.MessageDeserializer<S> deserializer)
public SubscriberIdentifier toIdentifier()
public SubscriberDeclaration toDeclaration()
public java.util.Collection<java.lang.String> getSupportedProtocols()
public boolean getLatchMode()
getLatchMode
in interface Subscriber<T>
true
if the Publisher
of this Subscriber
's
topic is latched, false
otherwisepublic void addMessageListener(org.ros.message.MessageListener<T> messageListener, int limit)
Subscriber
MessageListener
to be called when new messages are received.
The MessageListener
will be executed serially in its own thread. If
the MessageListener
processes 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.
addMessageListener
in interface Subscriber<T>
messageListener
- this MessageListener
will be called when new messages are
receivedlimit
- the maximum number of messages to bufferpublic void addMessageListener(org.ros.message.MessageListener<T> messageListener)
Subscriber
MessageListener
with a limit of 1.addMessageListener
in interface Subscriber<T>
Subscriber.addMessageListener(MessageListener, int)
public void addPublisher(PublisherIdentifier publisherIdentifier, java.net.InetSocketAddress address)
public void updatePublishers(java.util.Collection<PublisherIdentifier> publisherIdentifiers)
Publisher
s for the topic that this
Subscriber
is interested in.publisherIdentifiers
- Collection
of PublisherIdentifier
s for the
subscribed topicpublic void shutdown(long timeout, java.util.concurrent.TimeUnit unit)
Subscriber
Subscriber
. using the default
timeout Shutdown is delayed by at most the specified timeout to allow
SubscriberListener.onShutdown(Subscriber)
callbacks to complete.
SubscriberListener.onShutdown(Subscriber)
callbacks are executed in
separate threads.
shutdown
in interface Subscriber<T>
public void shutdown()
Subscriber
Subscriber
using the default timeout
for SubscriberListener.onShutdown(Subscriber)
callbacks.
SubscriberListener.onShutdown(Subscriber)
callbacks are executed in
separate threads.
shutdown
in interface Subscriber<T>
Subscriber.shutdown(long, TimeUnit)
public void addSubscriberListener(SubscriberListener<T> listener)
Subscriber
addSubscriberListener
in interface Subscriber<T>
listener
- The listener to add.public void signalOnMasterRegistrationSuccess()
SubscriberListener
s that the Subscriber
has
successfully registered with the master.
Each listener is called in a separate thread.
signalOnMasterRegistrationSuccess
in class DefaultTopicParticipant
public void signalOnMasterRegistrationFailure()
SubscriberListener
s that the Subscriber
has
failed to register with the master.
Each listener is called in a separate thread.
signalOnMasterRegistrationFailure
in class DefaultTopicParticipant
public void signalOnMasterUnregistrationSuccess()
SubscriberListener
s that the Subscriber
has
successfully unregistered with the master.
Each listener is called in a separate thread.
signalOnMasterUnregistrationSuccess
in class DefaultTopicParticipant
public void signalOnMasterUnregistrationFailure()
SubscriberListener
s that the Subscriber
has
failed to unregister with the master.
Each listener is called in a separate thread.
signalOnMasterUnregistrationFailure
in class DefaultTopicParticipant
public void signalOnNewPublisher(PublisherIdentifier publisherIdentifier)
SubscriberListener
s that a new Publisher
has
connected.
Each listener is called in a separate thread.
public java.lang.String toString()
toString
in class java.lang.Object