UA Bundle SDK .NET  2.2.1.258
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Groups Pages
Manage Subscription – Create Subscription

Prerequisites

A session with the server must be established.

Description

The following dialog shows an example dialog to create a subscription. Press the button “Show Code” to display the corresponding code, and the button “Help” to show this documentation page.

Enter the desired subscription parameters into the input field column at “Requested Parameters” and press the button “Create”. A new subscription will be created and the subscription parameters set by the server are displayed at “Revised Parameters”. Check the box in front of “Use Asynchronous Pattern” to call “BeginCreate” instead of “Create”.

Sample Code

The following code creates a new subscription using the requested subcription parameters and displays the revised parameters in the user interface.

try
{
// get the current session from the parent form.
Session session = m_parent.Session;
// nothing to do if no session.
if (session == null)
{
return;
}
// delete any existing subscription.
if (m_subscription != null)
{
m_subscription.Delete(new RequestSettings() { OperationTimeout = 5000 });
m_subscription = null;
}
// initialize subscription.
m_subscription = new Subscription(session);
m_subscription.PublishingInterval = (double)PublishingIntervalUD.Value;
m_subscription.MaxKeepAliveTime = (double)KeepAliveTimeUD.Value;
m_subscription.Lifetime = (double)LifeTimeUD.Value;
m_subscription.MaxNotificationsPerPublish = (uint)MaxNotificationsUD.Value;
m_subscription.Priority = (byte)PriorityUD.Value;
m_subscription.PublishingEnabled = PublishingEnabledCK.Checked;
// create subscription.
m_subscription.Create(new RequestSettings() { OperationTimeout = 10000 });
// update controls.
CurrentPublishingIntervalTB.Text = m_subscription.CurrentPublishingInterval.ToString();
CurrentKeepAliveTimeTB.Text = m_subscription.CurrentMaxKeepAliveTime.ToString();
CurrentLifeTimeTB.Text = m_subscription.CurrentLifetime.ToString();
CurrentMaxNotificationsTB.Text = m_subscription.CurrentMaxKeepAliveTime.ToString();
CurrentPriorityTB.Text = m_subscription.CurrentPriority.ToString();
CurrentPublishingEnabledCK.Checked = m_subscription.CurrentPublishingEnabled;
}
catch (Exception exception)
{
ExceptionDlg.Show(this.Text, exception);
}