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



IconMemberDescription
DirectoryUpdated(ISubscription, IDirectoryEvent)
Called when the contents of the directory change.

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 DirectoryUpdated(ISubscription, IDirectoryEvent) method should be coded to handle changes to the contents of the directory.

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.Directory;
using Caplin.StreamLink.Subscription;

namespace StreamLinkExamples.Directory
{
    public class ExampleDirectorySubscriptionListener: IDirectorySubscriptionListener
    {
        #region IDirectorySubscriptionListener Members

        /// <summary>
        /// Called when the directory contents changes.
        /// </summary>
        /// <param name="subscription">The subscription.</param>
        /// <param name="ev">The event.</param>
        /// <remarks>
        /// Updated occur subjects have been added to the directory and / or existing subjects may have been removed.
        /// </remarks>
        public void DirectoryUpdated(ISubscription subscription, IDirectoryEvent ev)
        {
            Console.WriteLine("DirectoryUpdated received for \"" +
                              ev.Subject + "\"");

            Console.WriteLine("Added: ");
            foreach (IDirectoryElement dirEl in ev.AddedElements)
            {
                Console.WriteLine("Subject: " + dirEl.Subject +
                                  ", Type: " + dirEl.SubjectType.ToString());
            }
        }

        #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.23.0 (5.0.23.0)