StreamLink.NET
IContainerSubscriptionListener Interface
StreamLink.NETCaplin.StreamLink.Subscription.ContainerIContainerSubscriptionListener
The IContainerSubscriptionListener interface allows applications to receive events raised for a container subscription.
Declaration Syntax
C#Visual BasicVisual C++
public interface IContainerSubscriptionListener : ISubscriptionListener
Public Interface IContainerSubscriptionListener _
	Implements ISubscriptionListener
public interface class IContainerSubscriptionListener : ISubscriptionListener
Members
All MembersMethods



IconMemberDescription
ContainerUpdated(ISubscription, IContainerEvent)
Called when the structure of the container changes.

SubscriptionErrorReceived(ISubscription, ISubscriptionErrorEvent)
Handles an event raised when there is an error in a subscription.
(Inherited from ISubscriptionListener.)
SubscriptionStatusUpdated(ISubscription, ISubscriptionStatusEvent)
Handles an event raised when there is a change in the status of a subscription.
(Inherited from ISubscriptionListener.)
Remarks

You must define a class that implements this interface. You implement each of the callback methods for the interface so that they handle the received events according to the needs of your application.

In particular, the ContainerUpdated(ISubscription, IContainerEvent) method should be coded to handle changes to the container structure. StreamLink does not invoke this callback when the data elements within the container are updated; in this case it invokes one or more of the callbacks for the listener associated with the type of data element.

For example, if the container elements are records, you must implement an IRecordSubscriptionListener and register this with the IContainerSubscription by setting the IContainerSubscription’s RecordSubscriptionListener property. StreamLink then passes updates to data records in the container to your IRecordSubscriptionListener, whereas it passes changes in the state of the container overall to your IContainerSubscriptionListener.

Note: StreamLink queues events in the order they were raised and passes each event in turn to an appropriate callback method of the relevant listener. All listener callbacks execute in the same dedicated worker thread,

Examples
CopyC#
using System;
using System.Collections.Generic;
using System.Text;
using Caplin.StreamLink.Subscription.Container;
using Caplin.StreamLink.Subscription;

namespace StreamLinkExamples.Container
{
    /// <summary>
    /// Basic example of an object implementing the IContainerSubscriptionListener
    /// interfance and querying the update objects for information.
    /// </summary>
    public class ExampleContainerSubscriptionListener: IContainerSubscriptionListener
    {
        #region IContainerSubscriptionListener Members

        /// <summary>
        /// Process the container change event.
        /// </summary>
        public void ContainerUpdated(ISubscription subscription, IContainerEvent ev)
        {
            // Process update
            string msg = "Received container structure change event for " +
                         ev.Subject + Environment.NewLine;

            msg += "Size:" + ev.Size + Environment.NewLine;
            msg += "Added constituents:" + Environment.NewLine;

            foreach (IContainerElement elem in ev.AddedElements)
            {
                msg += elem.Subject + " Type: " + elem.SubjectType +
                    Environment.NewLine;
            }
            msg += "Removed consitutents: " + Environment.NewLine;
            foreach (IContainerElement elem in ev.RemovedElements)
            {
                msg += elem.Subject + " Type: " + elem.SubjectType +
                    Environment.NewLine;
            }
            Console.WriteLine(msg);
        }

        #endregion

        #region ISubscriptionListener Members

        /// <summary>
        /// Subscription Ended Callback. For 'not found', 'read denied' etc.
        /// </summary>
        public void SubscriptionErrorReceived(ISubscription subscription,
                                              ISubscriptionErrorEvent ev)
        {
            Console.WriteLine("Subscription Status Update " + ev.Subject +
                               " Error: " + ev.Error.ToString());
        }

        /// <summary>
        /// Status Callback
        /// </summary>
        public void SubscriptionStatusUpdated(ISubscription subscription,
                                              ISubscriptionStatusEvent ev)
        {
            Console.WriteLine("Subscription Status Update " + ev.Subject +
                              " Status: " + ev.Status.ToString() +
                              " " + ev.Message);
        }

        #endregion
    }
}

Assembly: Caplin.StreamLink (Module: Caplin.StreamLink) Version: 5.0.14.0 (5.0.14.0)