public class DefaultPublisher<T> extends DefaultTopicParticipant implements Publisher<T>
Publisher.| Constructor and Description |
|---|
DefaultPublisher(NodeIdentifier nodeIdentifier,
TopicDeclaration topicDeclaration,
org.ros.message.MessageSerializer<T> serializer,
org.ros.message.MessageFactory messageFactory,
java.util.concurrent.ScheduledExecutorService executorService) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(PublisherListener<T> listener)
Add a new lifecycle listener to the
Publisher. |
void |
addSubscriber(SubscriberIdentifier subscriberIdentifer,
org.jboss.netty.channel.Channel channel)
Add a
Subscriber connection to this Publisher. |
org.jboss.netty.buffer.ChannelBuffer |
finishHandshake(ConnectionHeader incomingHeader)
Complete connection handshake on buffer.
|
PublisherIdentifier |
getIdentifier() |
boolean |
getLatchMode() |
int |
getNumberOfSubscribers()
Get the number of
Subscribers currently connected to the
Publisher. |
boolean |
hasSubscribers() |
T |
newMessage()
Create a new message.
|
void |
publish(T message)
Publishes a message.
|
void |
setLatchMode(boolean enabled) |
void |
shutdown()
Shuts down and unregisters the
Publisher using the default timeout
for PublisherListener.onShutdown(Publisher) callbacks. |
void |
shutdown(long timeout,
java.util.concurrent.TimeUnit unit)
Shuts down and unregisters the
Publisher. |
void |
signalOnMasterRegistrationFailure()
Signal all
PublisherListeners that the Publisher has failed
to register with the master. |
void |
signalOnMasterRegistrationSuccess()
Signal all
PublisherListeners that the Publisher has
successfully registered with the master. |
void |
signalOnMasterUnregistrationFailure()
Signal all
PublisherListeners that the Publisher has failed
to unregister with the master. |
void |
signalOnMasterUnregistrationSuccess()
Signal all
PublisherListeners that the Publisher has
successfully unregistered with the master. |
PublisherDeclaration |
toDeclaration() |
java.lang.String |
toString() |
getTopicDeclaration, getTopicDeclarationAsList, getTopicDeclarationHeader, getTopicMessageType, getTopicNameclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetTopicMessageType, getTopicNamepublic DefaultPublisher(NodeIdentifier nodeIdentifier, TopicDeclaration topicDeclaration, org.ros.message.MessageSerializer<T> serializer, org.ros.message.MessageFactory messageFactory, java.util.concurrent.ScheduledExecutorService executorService)
public void setLatchMode(boolean enabled)
setLatchMode in interface Publisher<T>enabled - true if published messages should be latched,
false otherwisepublic boolean getLatchMode()
getLatchMode in interface Publisher<T>true if published messages will be latched, false
otherwisepublic void shutdown(long timeout,
java.util.concurrent.TimeUnit unit)
PublisherPublisher. Shutdown is delayed by at
most the specified timeout to allow
PublisherListener.onShutdown(Publisher) callbacks to complete.
PublisherListener.onShutdown(Publisher) callbacks are executed in
separate threads.
public void shutdown()
PublisherPublisher using the default timeout
for PublisherListener.onShutdown(Publisher) callbacks.
PublisherListener.onShutdown(Publisher) callbacks are executed in
separate threads.
shutdown in interface Publisher<T>Publisher.shutdown(long, TimeUnit)public PublisherIdentifier getIdentifier()
public PublisherDeclaration toDeclaration()
public boolean hasSubscribers()
hasSubscribers in interface Publisher<T>true if getNumberOfSubscribers() > 0, false
otherwisepublic int getNumberOfSubscribers()
PublisherSubscribers currently connected to the
Publisher.
This counts the number of Subscriber registered. If a
Subscriber does not shutdown properly it will not be unregistered
and thus will contribute to this count.
getNumberOfSubscribers in interface Publisher<T>Subscribers currently connected to the
Publisherpublic T newMessage()
PublishernewMessage in interface Publisher<T>public void publish(T message)
PublisherPublisher has been associated with.public org.jboss.netty.buffer.ChannelBuffer finishHandshake(ConnectionHeader incomingHeader)
public void addSubscriber(SubscriberIdentifier subscriberIdentifer, org.jboss.netty.channel.Channel channel)
Subscriber connection to this Publisher.subscriberIdentifer - the SubscriberIdentifier of the new subscriberchannel - the communication Channel to the Subscriberpublic void addListener(PublisherListener<T> listener)
PublisherPublisher.addListener in interface Publisher<T>listener - the PublisherListener to addpublic void signalOnMasterRegistrationSuccess()
PublisherListeners that the Publisher has
successfully registered with the master.
Each listener is called in a separate thread.
signalOnMasterRegistrationSuccess in class DefaultTopicParticipantpublic void signalOnMasterRegistrationFailure()
PublisherListeners that the Publisher has failed
to register with the master.
Each listener is called in a separate thread.
signalOnMasterRegistrationFailure in class DefaultTopicParticipantpublic void signalOnMasterUnregistrationSuccess()
PublisherListeners that the Publisher has
successfully unregistered with the master.
Each listener is called in a separate thread.
signalOnMasterUnregistrationSuccess in class DefaultTopicParticipantpublic void signalOnMasterUnregistrationFailure()
PublisherListeners that the Publisher has failed
to unregister with the master.
Each listener is called in a separate thread.
signalOnMasterUnregistrationFailure in class DefaultTopicParticipantpublic java.lang.String toString()
toString in class java.lang.Object