コード例 #1
0
        public IEnumerator <ITask> SelectiveSubscribeHandler(SelectiveSubscribe subRequest)
        {
            submgr.InsertSubscription selectiveSubscription = new submgr.InsertSubscription(
                new submgr.InsertSubscriptionMessage(
                    subRequest.Body.Subscriber,
                    subRequest.Body.Expiration,
                    0));

            selectiveSubscription.Body.NotificationCount = subRequest.Body.NotificationCount;

            List <submgr.QueryType> subscribeFilter = new List <submgr.QueryType>();

            //items in this loop are OR'ed together in the subscription
            foreach (string s in subRequest.Body.Sensors)
            {
                LogInfo("Adding subscription for: " + s.ToUpper());

                //you can achieve an AND behavior by adding a list of strings in the new QueryType
                subscribeFilter.Add(new submgr.QueryType(s.ToUpper()));
            }

            selectiveSubscription.Body.QueryList = subscribeFilter.ToArray();
            subMgrPort.Post(selectiveSubscription);

            yield return(Arbiter.Choice(selectiveSubscription.ResponsePort,
                                        delegate(dssp.SubscribeResponseType response)
            {
                subRequest.ResponsePort.Post(response);
            },
                                        delegate(Fault fault)
            {
                subRequest.ResponsePort.Post(fault);
            }));

            yield break;
        }
コード例 #2
0
ファイル: Scribbler.cs プロジェクト: SamLin95/cs3630
        public IEnumerator<ITask> SelectiveSubscribeHandler(SelectiveSubscribe subRequest)
        {
            submgr.InsertSubscription selectiveSubscription = new submgr.InsertSubscription(
                new submgr.InsertSubscriptionMessage(
                    subRequest.Body.Subscriber,
                    subRequest.Body.Expiration,
                    0));

            selectiveSubscription.Body.NotificationCount = subRequest.Body.NotificationCount;

            List<submgr.QueryType> subscribeFilter = new List<submgr.QueryType>();

            //items in this loop are OR'ed together in the subscription
            foreach (string s in subRequest.Body.Sensors)
            {
                LogInfo("Adding subscription for: " + s.ToUpper());

                //you can achieve an AND behavior by adding a list of strings in the new QueryType
                subscribeFilter.Add(new submgr.QueryType(s.ToUpper()));
            }

            selectiveSubscription.Body.QueryList = subscribeFilter.ToArray();
            subMgrPort.Post(selectiveSubscription);

            yield return Arbiter.Choice(selectiveSubscription.ResponsePort,
                delegate(dssp.SubscribeResponseType response)
                {
                    subRequest.ResponsePort.Post(response);
                },
                delegate(Fault fault)
                {
                    subRequest.ResponsePort.Post(fault);
                });
            yield break;
        }