private void NodeResponse(IqResultEventArgs e, string ExpectedElement, bool Parameters, bool Messages, NodeInformationEventHandler Callback, object State) { XmlElement E; NodeInformation NodeInfo; if (e.Ok && (E = e.FirstElement) != null && E.LocalName == ExpectedElement) { NodeInfo = this.GetNodeInformation(E, Parameters, Messages); } else { e.Ok = false; NodeInfo = null; } if (Callback != null) { try { Callback(this, new NodeInformationEventArgs(NodeInfo, e)); } catch (Exception ex) { Log.Critical(ex); } } }
/// <summary> /// Gets information about a node in the concentrator. /// </summary> /// <param name="To">Address of server.</param> /// <param name="NodeID">Node ID</param> /// <param name="SourceID">Optional Source ID</param> /// <param name="Partition">Optional Partition</param> /// <param name="Parameters">If node parameters should be included in response.</param> /// <param name="Messages">If messages should be included in the response.</param> /// <param name="Language">Code of desired language.</param> /// <param name="ServiceToken">Optional Service token.</param> /// <param name="DeviceToken">Optional Device token.</param> /// <param name="UserToken">Optional User token.</param> /// <param name="Callback">Method to call when response is returned.</param> /// <param name="State">State object to pass on to callback method.</param> public void GetNode(string To, string NodeID, string SourceID, string Partition, bool Parameters, bool Messages, string Language, string ServiceToken, string DeviceToken, string UserToken, NodeInformationEventHandler Callback, object State) { StringBuilder Xml = new StringBuilder(); Xml.Append("<getNode xmlns='"); Xml.Append(ConcentratorServer.NamespaceConcentrator); Xml.Append("'"); this.AppendNodeAttributes(Xml, NodeID, SourceID, Partition); this.AppendTokenAttributes(Xml, ServiceToken, DeviceToken, UserToken); this.AppendNodeInfoAttributes(Xml, Parameters, Messages, Language); Xml.Append("'/>"); this.client.SendIqGet(To, Xml.ToString(), (sender, e) => { this.NodeResponse(e, "getNodeResponse", Parameters, Messages, Callback, State); }, State); }
/// <summary> /// Gets information about a node in the concentrator. /// </summary> /// <param name="To">Address of server.</param> /// <param name="Node">Node reference.</param> /// <param name="Parameters">If node parameters should be included in response.</param> /// <param name="Messages">If messages should be included in the response.</param> /// <param name="Language">Code of desired language.</param> /// <param name="ServiceToken">Optional Service token.</param> /// <param name="DeviceToken">Optional Device token.</param> /// <param name="UserToken">Optional User token.</param> /// <param name="Callback">Method to call when response is returned.</param> /// <param name="State">State object to pass on to callback method.</param> public void GetNode(string To, IThingReference Node, bool Parameters, bool Messages, string Language, string ServiceToken, string DeviceToken, string UserToken, NodeInformationEventHandler Callback, object State) { this.GetNode(To, Node.NodeId, Node.SourceId, Node.Partition, Parameters, Messages, Language, ServiceToken, DeviceToken, UserToken, Callback, State); }