StreamLink for Silverlight
Caplin.StreamLink.Subscription.Page Namespace
StreamLink for SilverlightCaplin.StreamLink.Subscription.Page
Contains interfaces, classes, and enums related to the Page SubjectType. Defines the key interfaces concerning the subscription to a page subject (IPageSubscription, IPageSubscriptionListener, the interface that provides access to the parameters used to request page objects, (IPageSubscriptionParameters), and the interface for handling page events (IPageEvent).
Declaration Syntax
C#Visual BasicVisual C++
namespace Caplin.StreamLink.Subscription.Page
Namespace Caplin.StreamLink.Subscription.Page
namespace Caplin.StreamLink.Subscription.Page
Types
All TypesInterfaces
IconTypeDescription
IPageCoordinate
The object representation of a coordinate (for example, a coordiante in an RTTP page). A coordinate is identified by an X- Position (XPos) and a Y-Position (YPos). This interface contains properties for retrieving the XPos and YPos values.

IPageData
The object representation of the data contained in a page (for example, data in an RTTP page). A Page Data contains the maximum number of Rows (MaxY) and maximum number of columns (MaxX) as well as an IDictionary object which maps an IPageCoordinate object(identified by an X- Position (XPos) and a Y-Position (YPos)) to a Line of data(text). This interface contains properties for retrieving the IPageCoordinate, MaxX and MaxY values. Note: For a page update, the MaxY and MaxX values will be -1

IPageEvent
Provides information about a change to story data in a Story (SubjectType Story).

IPageSubscription
Represents a Subscription to a page Subject

IPageSubscriptionListener
Interface used to listen to Page update events

IPageSubscriptionParameters
Used to set the subscription parameters for the Page object

Remarks

Page subscriptions are created through the IStreamLinkProvider interface using one of the CreatePageSubscription(IPageSubscriptionListener, String, IPageSubscriptionParameters) methods. In all cases an IPageSubscriptionListener must be passed along with the name of the page object being subscribed to.

CopyC#
using System;
using System.Collections.Generic;
using System.Text;
using Caplin.StreamLink.Subscription.Page;
using Caplin.StreamLink.Subscription;
using Caplin.StreamLink;
using Caplin.StreamLink.Configuration;
using Caplin.StreamLink.Authentication;
using System.Threading;
using Caplin.StreamLink.Logging;

namespace StreamLinkExamples.Page
{
    public class CreatePageSubscriptionFull
    {
        // Subscription Listener class to be informed about all Subscription information
        class MyPageSubscriptionListener : IPageSubscriptionListener
        {
            #region IPageSubscriptionListener Members

            void IPageSubscriptionListener.PageUpdated(ISubscription subscription, IPageEvent ev)
            {
                // Process update
                Console.WriteLine("Page Updated received for \"" +
                                  ev.Subject + "\"");


                IPageCoordinate pageCoordinate = null;

                foreach (var pair in ev.PageData.DataSlice)
                {
                    pageCoordinate = pair.Key;
                    Console.WriteLine("Page coordinate being updated:  Max Rows: {0}\tMax Columns: {1}\tRow Number: {2}\tColumn Number: {3}\tValue; {4}", ev.PageData.MaxX, ev.PageData.MaxY, pageCoordinate.YPos, pageCoordinate.XPos, pair.Value);
                }
            }

            #endregion

            #region ISubscriptionListener Members

            public void SubscriptionErrorReceived(ISubscription subscription, ISubscriptionErrorEvent ev)
            {
                // Process Subscription error
                Console.WriteLine("Subscription Status Update " + ev.Subject + " Error: " + ev.Error.ToString());
            }

            public void SubscriptionStatusUpdated(ISubscription subscription, ISubscriptionStatusEvent status)
            {
                // Process Subscription status callback
                Console.WriteLine("Subscription Status Update " + status.Subject + " Status: " + status.Status.ToString() + " " + status.Message);
            }

            #endregion
        }

        // Main execution method
        static void Example()
        {
            // Create basic streamlink
            IStreamLinkConfiguration myConfiguration = SimpleConfiguration.CreateType2HttpConnection("localvm", 45730);
            IStreamLink myStreamLink = new StreamLink(myConfiguration);
            myStreamLink.CredentialsProvider = new PasswordCredentialsProvider("admin", "admin");
            myStreamLink.StreamLinkProvider.Connect();

            //uncomment to include logging
            //myStreamLink.Logger = new ConsoleLogger();

            // Create Listener object
            IPageSubscriptionListener listener = new MyPageSubscriptionListener();

            //Create row parameter
            IPageSubscriptionParameters parameters = myStreamLink.StreamLinkProvider.ParametersFactory.CreatePageSubscriptionParameters(new int[] { 3, 5, 7, 11 });

            //subscribes to all Rows
            //Parameters = myStreamLink.StreamLinkProvider.ParametersFactory.CreatePageSubscriptionParameters(new int[] { });


            IPageSubscription mySubscription = myStreamLink.StreamLinkProvider.CreatePageSubscription(listener,
                                                                                                          "/DEMO/PAGE1",
                                                                                                          parameters);

            // Finally, subscribe
            mySubscription.Subscribe();

            // Sleep so we see some updates being received.
            Thread.Sleep(20000);


            mySubscription.Unsubscribe();
            myStreamLink.StreamLinkProvider.Disconnect();

        }

    }
}

The object implementing IPageSubscriptionListener will then be informed of all subscription status, error, and update events. (Also see ISubscriptionListener.)