示例#1
0
        public void UnsubscribeFromEvents()
        {
            this.unsubscribed = true;

            if (this.timer != null)
            {
                this.timer.Dispose();
                this.timer = null;
            }

            XmppConcentrator Concentrator = this.Concentrator;

            if (Concentrator is null)
            {
                return;
            }

            XmppAccountNode XmppAccountNode = Concentrator.XmppAccountNode;

            if (XmppAccountNode is null)
            {
                return;
            }

            string             FullJid            = Concentrator.FullJid;
            ConcentratorClient ConcentratorClient = XmppAccountNode?.ConcentratorClient;

            if (ConcentratorClient is null)
            {
                return;
            }

            XmppAccountNode.ConcentratorClient.Unsubscribe(FullJid, this.key, SourceEventType.All, "en",
                                                           string.Empty, string.Empty, string.Empty, null, null);
        }
示例#2
0
        public void SubscribeToEvents()
        {
            if (this.unsubscribed)
            {
                return;
            }

            XmppConcentrator Concentrator = this.Concentrator;

            if (Concentrator is null)
            {
                return;
            }

            XmppAccountNode XmppAccountNode = Concentrator.XmppAccountNode;

            if (XmppAccountNode is null)
            {
                return;
            }

            string             FullJid            = Concentrator.FullJid;
            ConcentratorClient ConcentratorClient = XmppAccountNode?.ConcentratorClient;

            if (ConcentratorClient is null)
            {
                return;
            }

            if (this.timer != null)
            {
                this.timer.Dispose();
                this.timer = null;
            }

            ConcentratorClient.Subscribe(FullJid, this.key, 600, SourceEventType.All, true, true, "en",
                                         string.Empty, string.Empty, string.Empty, (sender, e) =>
            {
                if (e.Ok)
                {
                    this.timer = new Timer((P) =>
                    {
                        this.SubscribeToEvents();
                    }, null, 300000, 300000);
                }

                return(Task.CompletedTask);
            }, null);
        }
示例#3
0
        public override void GetConfigurationForm(DataFormResultEventHandler Callback, object State)
        {
            XmppConcentrator Concentrator    = this.Concentrator;
            XmppAccountNode  XmppAccountNode = Concentrator.XmppAccountNode;
            ControlClient    ControlClient;

            if (XmppAccountNode != null && (ControlClient = XmppAccountNode.ControlClient) != null)
            {
                ControlClient.GetForm(Concentrator.RosterItem.LastPresenceFullJid, "en", Callback, State,
                                      new ThingReference(this.nodeInfo.NodeId, this.nodeInfo.SourceId, this.nodeInfo.Partition));
            }
            else
            {
                throw new NotSupportedException();
            }
        }
示例#4
0
        public override SensorDataClientRequest StartSensorDataFullReadout()
        {
            XmppConcentrator Concentrator    = this.Concentrator;
            XmppAccountNode  XmppAccountNode = Concentrator.XmppAccountNode;
            SensorClient     SensorClient;

            if (XmppAccountNode != null && (SensorClient = XmppAccountNode.SensorClient) != null)
            {
                return(SensorClient.RequestReadout(Concentrator.RosterItem.LastPresenceFullJid,
                                                   new ThingReference[] { new ThingReference(this.nodeInfo.NodeId, this.nodeInfo.SourceId, this.nodeInfo.Partition) }, FieldType.All));
            }
            else
            {
                throw new NotSupportedException();
            }
        }
示例#5
0
        public override SensorDataSubscriptionRequest SubscribeSensorDataMomentaryReadout(FieldSubscriptionRule[] Rules)
        {
            XmppConcentrator Concentrator    = this.Concentrator;
            XmppAccountNode  XmppAccountNode = Concentrator.XmppAccountNode;
            SensorClient     SensorClient;

            if (XmppAccountNode != null && (SensorClient = XmppAccountNode.SensorClient) != null)
            {
                return(SensorClient.Subscribe(Concentrator.RosterItem.LastPresenceFullJid,
                                              new ThingReference[] { new ThingReference(this.nodeInfo.NodeId, this.nodeInfo.SourceId, this.nodeInfo.Partition) },
                                              FieldType.Momentary, Rules, new Duration(false, 0, 0, 0, 0, 0, 1), new Duration(false, 0, 0, 0, 0, 1, 0), false));
            }
            else
            {
                return(null);
            }
        }