Summary: Registering to Space events
OverviewIt is possible to subscribe to different space events and be notified of changes inside the space that match the event subscription. These notifications are pushed from the space to the proxy, unlike the opposite way, where the proxy executes queries on the space. This page demonstrates a basic event usage scenario. Event RegistrationSubscribing to an event is done using an IDataEventSession with a template, an event type and a callback method. ISpaceProxy has a default data event session that can be used for subscription. The following example demonstrates simple events usage: public class Person { private String _userId; public String UserId { get { return _userId; } set { _userId = value; } } ... public Person() { } } ... //Callback method that is triggered when the event fires void Space_PersonChanged(object sender, SpaceDataEventArgs<Person> e) { Console.WriteLine("Person with UserId: " + e.Object.UserId + " was written to the space); } //Event subscription IEventRegistration registration = proxy.DefaultDataEventSession.AddListener(new Person(), Space_PersonChanged, DataEventType.Write); Any new person entries that are written to the space, trigger the event and execute the Space_PersonChanged callback method at the client side. IEventRegistration registration = proxy.DefaultDataEventSession.AddListener(new Person(),
Space_PersonChanged,
DataEventType.Write | DataEventType.Update);
When the events are no longer relevant, the registration for the events should be removed, to reduce the load on the space. proxy.DefaultDataEventSession.RemoveListener(registration);
|
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |