
Listeners can be registered using the addListener() methods and receive an EventRegistration that will be used to unregister using the removeListener().
When a listener is detroyed it automaticaly unregister.
Sample usage:
Here is an example of using DataEventSession for registring a listener over matching entries:
// Prepare the session
EventSessionFactoryPtr factory( EventSessionFactory::getFactory(spaceProxy));
// create a session configuration
EventSessionConfigPtr config( EventSessionConfig::CreateSessionConfig(spaceProxy));
config->setComType(ComType::UNICAST); // or MULTIPLEX,MULTICAST
// creating a new DataEventSession
DataEventSessionPtr session (factory->newDataEventSession(config) );
// Create the listener using the class we defined
PersonNotifyListener listener;
// Register for notifications by adding the listener to the space with the Person template
Person personTemplate;
EventRegistrationPtr reg( session->addListener( &personTemplate, &listener, Lease::FOREVER, NotifyModifiers::NOTIFY_WRITE));
Public Member Functions | |
| EventRegistrationPtr | addListener (const SqlQuery &sqlQuery, IRemoteEventListener *pListener, long long timeout=MAX_TIMEOUT, int actionTypes=NotifyModifiers::NOTIFY_ALL) |
| Registers a listener with a space using a template. | |
| EventRegistrationPtr | addListener (IEntry *pIEntryTemplate, IRemoteEventListener *pListener, long long timeout=MAX_TIMEOUT, int actionTypes=NotifyModifiers::NOTIFY_ALL) |
| Registers a listener with a space using a template. | |
| virtual void | close () |
| Closes the session and unregisters all listeners. | |
| void | removeListener (EventRegistrationPtr registration) |
| Unregisters the listener from the space. | |
| EventRegistrationPtr DataEventSession::addListener | ( | const SqlQuery & | sqlQuery, | |
| IRemoteEventListener * | pListener, | |||
| long long | timeout = MAX_TIMEOUT, |
|||
| int | actionTypes = NotifyModifiers::NOTIFY_ALL | |||
| ) |
Registers a listener with a space using a template.
| sqlQuery | - SqlQuery object used for matching. | |
| pListener | - user defined listener implementing IRemoteEventListener | |
| timeout | - the time duration in which the listener will be receiving calls. Default value is MAX_TIMEOUT. | |
| actionTypes | - the type of actions you wish to receive notification on, see NotifyModifiers. Default value is NotifyModifiers::NOTIFY_ALL. |
| RemoteException | if the space has failed to perform the registration | |
| TransactionException | if the transaction associated with this session has expired. |
| EventRegistrationPtr DataEventSession::addListener | ( | IEntry * | pIEntryTemplate, | |
| IRemoteEventListener * | pListener, | |||
| long long | timeout = MAX_TIMEOUT, |
|||
| int | actionTypes = NotifyModifiers::NOTIFY_ALL | |||
| ) |
Registers a listener with a space using a template.
| pIEntryTemplate | - Pointer to an IEntry template used for matching. | |
| pListener | - user defined listener implementing IRemoteEventListener | |
| timeout | - the time duration in which the listener will be receiving calls. Default value is MAX_TIMEOUT. | |
| actionTypes | - the type of actions you wish to receive notification on, see NotifyModifiers. Default value is NotifyModifiers::NOTIFY_ALL. |
| RemoteException | if the space has failed to perform the registration | |
| TransactionException | if the transaction associated with this session has expired. |
| void DataEventSession::close | ( | void | ) | [virtual] |
Closes the session and unregisters all listeners.
| RemoteException | if the remove space failed to remove the notification registration. | |
| UnknownLeaseException | if the listeners lease has expired. |
Implements EventSession.
| void DataEventSession::removeListener | ( | EventRegistrationPtr | registration | ) |
Unregisters the listener from the space.
| registration | - the registration object received from the server when the listener was added. |
| RemoteException | if the space has failed to unregister the listener. | |
| UnknownLeaseException | if the lease of the registration is invalid. |
1.5.3