public class SpreadMultiReceiver extends Object
SpreadReceiver
by synchronizing the required access and
calculating the effective scopes to join. The underlying
SpreadReceiver
is activated and deactivated depending on the
currently active subscriptions to ensure proper termination in case the last
client left.
Users of this class call subscribe(Subscription)
once they want to
start receiving events via this class and use
unsubscribe(Subscription)
to stop this by reusing the same
SpreadMultiReceiver.Subscription
instance.
TODO the whole scope logic in here currently does not calculate the effective
root scopes and therefore possibly joins too many scopes. Spread ensures that
events are still received only once, but I don't know what the performance
impact is.Modifier and Type | Class and Description |
---|---|
static class |
SpreadMultiReceiver.Subscription
Subscription information for a single client of this class.
|
Constructor and Description |
---|
SpreadMultiReceiver(SpreadReceiver spread)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
URI |
getTransportUri()
Returns a URI representing the RSB transport encapsulated by this
instance.
|
boolean |
subscribe(SpreadMultiReceiver.Subscription subscription)
Register a new client.
|
boolean |
unsubscribe(SpreadMultiReceiver.Subscription subscription)
Unregister an existing client.
|
public SpreadMultiReceiver(SpreadReceiver spread)
spread
- the spread receiver to use. Must not be active when passed
into this class, not null
public boolean subscribe(SpreadMultiReceiver.Subscription subscription) throws RSBException
subscription
- the subscription specifying the client needs, not
null
true
if the client was successfully subscribed and
did not exist beforeRSBException
- errorpublic boolean unsubscribe(SpreadMultiReceiver.Subscription subscription) throws RSBException, InterruptedException
subscription
- existing subscription to remove, not null
true
if the subscription existed and was removed
successfullyRSBException
- errorInterruptedException
- interrupted while waiting for the subscription to become
effectively unregisteredpublic URI getTransportUri()
Copyright © 2018 CoR-Lab. All rights reserved.