Example #1
0
        /// <summary>
        /// Asynchronously calls the CreateSubscription service.
        /// </summary>
        public virtual IAsyncResult BeginCreateSubscription(CreateSubscriptionMessage message, AsyncCallback callback, object callbackData)
        {
            try
            {
                // check for bad data.
                if (message == null) throw new ArgumentNullException("message");

                // set the request context.
                SetRequestContext(RequestEncoding.Xml);

                // create handler.
                ProcessRequestAsyncResult result = new ProcessRequestAsyncResult(this, callback, callbackData, 0);
                return result.BeginProcessRequest(SecureChannelContext.Current, message.CreateSubscriptionRequest);
            }
            catch (Exception e)
            {
                throw CreateSoapFault(message.CreateSubscriptionRequest, e);
            }
        }
Example #2
0
        /// <summary>
        /// The operation contract for the CreateSubscription service.
        /// </summary>
        public virtual CreateSubscriptionResponseMessage CreateSubscription(CreateSubscriptionMessage request)
        {
            CreateSubscriptionResponse response = null;

            try
            {
                // OnRequestReceived(message.CreateSubscriptionRequest);

                SetRequestContext(RequestEncoding.Xml);
                response = (CreateSubscriptionResponse)CreateSubscription(request.CreateSubscriptionRequest);
                // OnResponseSent(response);
                return new CreateSubscriptionResponseMessage(response);
            }
            catch (Exception e)
            {
                Exception fault = CreateSoapFault(request.CreateSubscriptionRequest, e);
                // OnResponseFaultSent(fault);
                throw fault;
            }
        }
Example #3
0
 /// <summary>
 /// The operation contract for the CreateSubscription service.
 /// </summary>
 public virtual CreateSubscriptionResponseMessage CreateSubscription(CreateSubscriptionMessage request)
 {
     try
     {
         SetRequestContext(RequestEncoding.Xml);
         CreateSubscriptionResponse response = (CreateSubscriptionResponse)CreateSubscription(request.CreateSubscriptionRequest);
         return new CreateSubscriptionResponseMessage(response);
     }
     catch (Exception e)
     {
         throw CreateSoapFault(request.CreateSubscriptionRequest, e);
     }
 }
Example #4
0
        /// <summary>
        /// Creates a subscription that can be used to recieve data change or event notifications. 
        /// </summary>
        public CreateSubscriptionResponseMessage CreateSubscription(CreateSubscriptionMessage request)
        {
            try
            {
                lock (m_lock)
                {
                    // verify the session.
                    Session session = VerifySession(request.RequestHeader, false);

                    // create a new subscription.
                    Subscription subscription = new Subscription();

                    uint subscriptionId;
                    double publishingInterval;
                    uint lifetimeCount;
                    uint keepAliveCount;

                    // the subscription validates the parameters and throws exceptions on error.
                    subscription.Create(
                        session,
                        m_nodeManager,
                        request.RequestedPublishingInterval,
                        request.RequestedLifetimeCount,
                        request.RequestedMaxKeepAliveCount,
                        request.MaxNotificationsPerPublish,
                        request.PublishingEnabled,
                        request.Priority,
                        out subscriptionId,
                        out publishingInterval,
                        out lifetimeCount,
                        out keepAliveCount);

                    // save the subscription.
                    m_subscriptions.Add(subscriptionId, subscription);

                    // start the publish thread if it has not already been started.
                    if (m_subscriptions.Count == 1)
                    {
                        ThreadPool.QueueUserWorkItem(PublishSubscriptions);
                    }

                    // return the response.
                    CreateSubscriptionResponseMessage response = new CreateSubscriptionResponseMessage();

                    response.ResponseHeader = CreateResponseHeader(request.RequestHeader);
                    response.SubscriptionId = subscriptionId;
                    response.RevisedPublishingInterval = publishingInterval;
                    response.RevisedLifetimeCount = lifetimeCount;
                    response.RevisedMaxKeepAliveCount = keepAliveCount;

                    return response;
                }
            }
            catch (Exception e)
            {
                throw CreateSoapFault(request.RequestHeader, e);
            }
        }