class PublisherConsistencyListener(SubscribeListener):
This class is used to solve the problem that sometimes we create a publisher and then immediately publish a message, before the subscribers have set up their connections.
Call attach() to attach the listener to a publisher. It sets up a buffer of outgoing messages, then when a new connection occurs, sends the messages in the buffer.
Call detach() to detach the listener from the publisher and restore the original publish methods.
After some particular timeout (default to 1 second), the listener stops buffering messages as it is assumed by this point all subscribers will have successfully set up their connections.
Method | attach |
Overrides the publisher's publish method, and attaches a subscribe listener to the publisher, effectively routing incoming connections and outgoing publish requests through this class instance |
Method | detach |
Restores the publisher's original publish method and unhooks the subscribe listeners, effectively finishing with this object |
Method | peer |
Called whenever there's a new subscription. |
Method | publish |
The publisher's publish method is replaced with this publish method which checks for timeout and if we haven't timed out, buffers outgoing messages in preparation for new subscriptions |
Method | timed |
Checks to see how much time has elapsed since the publisher was created |
Class Variable | timeout |
Undocumented |
Instance Variable | attached |
Undocumented |
Instance Variable | established |
Undocumented |
Instance Variable | lock |
Undocumented |
Instance Variable | msg |
Undocumented |
Instance Variable | publish |
Undocumented |
Instance Variable | publisher |
Undocumented |
Overrides the publisher's publish method, and attaches a subscribe listener to the publisher, effectively routing incoming connections and outgoing publish requests through this class instance
Restores the publisher's original publish method and unhooks the subscribe listeners, effectively finishing with this object
Called whenever there's a new subscription.
If we're still inside the subscription setup window, then we publish any buffered messages to the peer.
We also check if we're timed out, but if we are we don't detach (due to threading complications), we just don't propagate buffered messages