This class is a converter (or adapter, as used in [GHJV95]) between the pull-style of actively having to receive messages and the push-style where clients register a callback function / method which is invoked whenever a message has been received. It allows a client of a channel to be notified when messages have been received instead of having to actively poll the channel for new messages. This eliminates any need for the clients to allocate a separate thread for receiving messages.
A PullPushAdapter is always created with a reference to a class that implements interface Transportable (e.g. a channel). Clients interested in being called when a message is received can register with the PullPushAdapter using method AddListener. They have to implement interface MessageListener, whose Receive method will be called when a message arrives. Any number of clients can register and all of their Receive methods will be called when a message arrives.
Upon creation, an instance of PullPushAdapter creates at least one thread2.4 which constantly calls the Receive method of the underlying Transportable instance (e.g. a channel). When a message is received, if there are any registered message listeners, all of them will be called (that is, method Receive will be invoked) in turn.
As this class does not implement interface Transportable, but uses it for receiving messages, an underlying object has to be used to send messages (e.g. the channel on top of which an object of this class resides).