[This is preliminary documentation and is subject to change.]
| C# | Visual Basic | Visual C++ |
public interface ISubscriber
Public Interface ISubscriber
public interface class ISubscriber
| All Members | Methods | ||||
| Icon | Member | Description |
|---|---|---|
| OnEvent(Event, IZone, IMessageInfo) | Respond to a SIF_Event received from a zone. |
An Event is a notification to subscribing agents that a data object has been added, changed, or deleted in the reporting application's database. In the Schools Interoperability Framework, any agent may report SIF_Event messages for any object, even if that agent is not the authoritative publisher of the object.
Subscribing to SIF Events
Agents that wish to receive SIF_Event messages must register with the zone integration server as a Subscriber of one or more SIF Data Object types. To subscribe to events for a specific object type, register a Subscriber message handler with Zone or Topic instances. When registering Subscribers with zones, repeatedly call the {@linkplain com.edustructures.sifworks.Zone#setSubscriber(Subscriber, ElementDef, int)} method for each SIF Data Object type you wish to subscribe to. When registering message handlers with Topics, call the {@linkplain com.edustructures.sifworks.Topic#setSubscriber(Subscriber, int)} method once to register with all zones bound to the topic (your Subscriber implementation will be called whenever a SIF_Event is received on any of the zones bound to that topic.) Be sure to specify the ADKFlags.PROV_SUBSCRIBE flag as the last parameter to these methods if you wish the ADK to send a SIF_Subscribe message to the zone when it connects.
When a SIF_Event message is received, it is dispatched to the appropriate Subscriber message handler's onEvent method for processing. Obtain a DataObjectInputStream from the Event instance by calling the Event parameter's {@linkplain com.edustructures.sifworks.Event#getData()} method, then repeatedly call the stream's {@linkplain com.edustructures.sifworks.DataObjectInputStream#readDataObject()} method to get the next SIFDataObject in the event payload.public void OnEvent( Event evnt, IZone zone, IMessageInfo info ) { IDataObjectInputStream payload = evnt.Data; while( payload.Available ) { StudentPersonal sp = (StudentPersonal)payload.ReadDataObject(); switch( event.Action ) { case EventAction.Add: // Add student... break; case EventActon.Change: // Change student... break; case EventAction.Delete: // Delete student... break; } } }
If OnEvent returns successfully, the ADK acknowledges the SIF_Event message with a success SIF_Ack. If a SifException or other AdkException is thrown, the ADK acknowledges the SIF_Event with an error SIF_Ack using the error category, code, and description from the exception.