Internal Constructs a new MapEventsManager
the NamedMap to manage events for
the associated Session
the gRPC interface for making requests
the Serializer used by this map
the EventEmitter to use
Protected clientThe gRPC service client.
Protected mapThe map name for which events are received.
Protected namedThe NamedMap used as the source of the events.
Protected reqRequest factory.
Unsubscribe the filter ID and filter from their associated maps.
the filter ID
the filter
Registers the specified listener to listen for events matching the provided filter.
the MapListener
the filter associated with the listener
true if the event should only include the key, or false
if the event should include old and new values as well as the key
Registers the specified listener to listen for events matching the provided key.
the MapListener
the map key to listen to
true if the event should only include the key, or false
if the event should include old and new values as well as the key
Removes the registration of the listener for the provided filter.
the MapListener
the MapEventFilter associated with the listener
Removes the registration of the listener for the provided key.
the MapListener
the key associated with the listener
MapEventsManager handles registration, de-registration of callbacks, and notification of MapEvents to callbacks. Since multiple callbacks can be registered for a single key / filter, this class relies on another internal class called ListenerGroup which maintains the collection of callbacks.
There are two maps that are maintained:
A Map of string keys mapped to a ListenerGroup, which is used to identify the group of callbacks for a single key. We stringify the key since Javascript is not the same as Java's equals().
A Map of filter => ListenerGroup that is used to identify the group of callbacks for a MapEventFilter.
When a filter is subscribed, the server responds with a unique filterID. This filterID is what is specified is a MapEvent. So, this class maintains a third Map of filterID to ListenerGroup for efficiently identifying the ListenerGroup for a filterID.
This class also lazily creates the "events" stream (a bidi stream). When the first callback is registered, this class calls the "events()" method on the NamedCacheClient and obtains the duplex stream. Similarly, it closes the stream when the last callback is unregistered.