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
Subscriber s 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
PublisherListener s that the Publisher has failed
to register with the master. |
void |
signalOnMasterRegistrationSuccess()
Signal all
PublisherListener s that the Publisher has
successfully registered with the master. |
void |
signalOnMasterUnregistrationFailure()
Signal all
PublisherListener s that the Publisher has failed
to unregister with the master. |
void |
signalOnMasterUnregistrationSuccess()
Signal all
PublisherListener s that the Publisher has
successfully unregistered with the master. |
PublisherDeclaration |
toDeclaration() |
java.lang.String |
toString() |
getTopicDeclaration, getTopicDeclarationAsList, getTopicDeclarationHeader, getTopicMessageType, getTopicName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getTopicMessageType, getTopicName
public 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)
Publisher
Publisher
. 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()
Publisher
Publisher
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()
Publisher
Subscriber
s 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>
Subscriber
s currently connected to the
Publisher
public T newMessage()
Publisher
newMessage
in interface Publisher<T>
public void publish(T message)
Publisher
Publisher
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 Subscriber
public void addListener(PublisherListener<T> listener)
Publisher
Publisher
.addListener
in interface Publisher<T>
listener
- the PublisherListener
to addpublic void signalOnMasterRegistrationSuccess()
PublisherListener
s that the Publisher
has
successfully registered with the master.
Each listener is called in a separate thread.
signalOnMasterRegistrationSuccess
in class DefaultTopicParticipant
public void signalOnMasterRegistrationFailure()
PublisherListener
s that the Publisher
has failed
to register with the master.
Each listener is called in a separate thread.
signalOnMasterRegistrationFailure
in class DefaultTopicParticipant
public void signalOnMasterUnregistrationSuccess()
PublisherListener
s that the Publisher
has
successfully unregistered with the master.
Each listener is called in a separate thread.
signalOnMasterUnregistrationSuccess
in class DefaultTopicParticipant
public void signalOnMasterUnregistrationFailure()
PublisherListener
s that the Publisher
has failed
to unregister with the master.
Each listener is called in a separate thread.
signalOnMasterUnregistrationFailure
in class DefaultTopicParticipant
public java.lang.String toString()
toString
in class java.lang.Object