示例#1
0
        /// <summary>
        /// Send a message to the resource being observed that we want to cancel
        /// the observation.
        /// </summary>
        public void ProactiveCancel()
        {
            Request cancel = Request.NewGet();

            // copy options, but set Observe to cancel
            cancel.SetOptions(Request.GetOptions());
            cancel.MarkObserveCancel();
            // use same Token
            cancel.Token       = Request.Token;
            cancel.Destination = Request.Destination;

            // dispatch final response to the same message observers
            cancel.CopyEventHandler(Request);

            cancel.Send(_endpoint);
            // cancel old ongoing request
            Request.IsCancelled = true;
            Canceled            = true;
        }
示例#2
0
        public void UpdateETags(byte[][] eTags)
        {
            Request newRequest = Request.NewGet();

            //  Copy over the options
            newRequest.SetOptions(Request.GetOptions());
            newRequest.ClearETags();
            foreach (byte[] tag in eTags)
            {
                newRequest.AddETag(tag);
            }

            newRequest.Token       = Request.Token;
            newRequest.Destination = Request.Destination;
            newRequest.CopyEventHandler(Request);
            newRequest.Reregistering  += OnReregister;
            newRequest.ObserveRelation = this;

            newRequest.Send(_endpoint);
            Request = newRequest;
        }