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
{
Session session = m_parent.Session;
if (session == null)
{
return;
}
if (m_subscription != null)
{
m_subscription.Delete(new RequestSettings() { OperationTimeout = 5000 });
m_subscription = null;
}
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;
m_subscription.Create(new RequestSettings() { OperationTimeout = 10000 });
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);
}