/// <summary> /// Registers a thing in the Thing Registry. Only things that does not have an owner can register with the Thing Registry. /// Things that have an owner should call <see cref="UpdateThing(string, string, string, MetaDataTag[], UpdateEventHandler, object)"/> /// to update its meta-data in the Thing Registry, if the meta-data has changed. /// </summary> /// <param name="SelfOwned">If the thing is owned by itself.</param> /// <param name="NodeId">Node ID of thing, if behind a concentrator.</param> /// <param name="SourceId">Source ID of thing, if behind a concentrator.</param> /// <param name="Partition">Partition of thing, if behind a concentrator.</param> /// <param name="MetaDataTags">Meta-data tags to register with the registry.</param> /// <param name="Callback">Callback method to call when response is returned.</param> /// <param name="State">State object to pass on to the callback method.</param> public void RegisterThing(bool SelfOwned, string NodeId, string SourceId, string Partition, MetaDataTag[] MetaDataTags, RegistrationEventHandler Callback, object State) { StringBuilder Request = new StringBuilder(); Request.Append("<register xmlns='"); Request.Append(NamespaceDiscovery); this.AddNodeInfo(Request, NodeId, SourceId, Partition); if (SelfOwned) { Request.Append("' selfOwned='true"); } Request.Append("'>"); string RegistryAddress = this.AddTags(Request, MetaDataTags, this.thingRegistryAddress); Request.Append("</register>"); this.client.SendIqSet(RegistryAddress, Request.ToString(), (sender, e) => { if (Callback != null) { XmlElement E = e.FirstElement; string OwnerJid = string.Empty; bool IsPublic = false; if (e.Ok && E != null && E.LocalName == "claimed" && E.NamespaceURI == NamespaceDiscovery) { OwnerJid = XML.Attribute(E, "jid"); IsPublic = XML.Attribute(E, "public", false); if (string.IsNullOrEmpty(NodeId) && string.IsNullOrEmpty(SourceId) && string.IsNullOrEmpty(Partition) && this.client.TryGetExtension(typeof(ProvisioningClient), out IXmppExtension Extension) && Extension is ProvisioningClient ProvisioningClient) { ProvisioningClient.OwnerJid = OwnerJid; } } RegistrationEventArgs e2 = new RegistrationEventArgs(e, State, OwnerJid, IsPublic); try { Callback(this, e2); } catch (Exception ex) { Log.Critical(ex); } } }, null); }
/// <summary> /// Registers a thing in the Thing Registry. Only things that does not have an owner can register with the Thing Registry. /// Things that have an owner should call <see cref="UpdateThing(string, string, string, MetaDataTag[], UpdateEventHandler, object)"/> /// to update its meta-data in the Thing Registry, if the meta-data has changed. /// </summary> /// <param name="NodeId">Node ID of thing, if behind a concentrator.</param> /// <param name="SourceId">Source ID of thing, if behind a concentrator.</param> /// <param name="Partition">Partition of thing, if behind a concentrator.</param> /// <param name="MetaDataTags">Meta-data tags to register with the registry.</param> /// <param name="Callback">Callback method to call when response is returned.</param> /// <param name="State">State object to pass on to the callback method.</param> public void RegisterThing(string NodeId, string SourceId, string Partition, MetaDataTag[] MetaDataTags, RegistrationEventHandler Callback, object State) { this.RegisterThing(false, NodeId, SourceId, Partition, MetaDataTags, Callback, State); }
/// <summary> /// Registers a thing in the Thing Registry. Only things that does not have an owner can register with the Thing Registry. /// Things that have an owner should call <see cref="UpdateThing(string, string, MetaDataTag[], UpdateEventHandler, object)"/> /// to update its meta-data in the Thing Registry, if the meta-data has changed. /// </summary> /// <param name="SelfOwned">If the thing is owned by itself.</param> /// <param name="NodeId">Node ID of thing, if behind a concentrator.</param> /// <param name="SourceId">Source ID of thing, if behind a concentrator.</param> /// <param name="MetaDataTags">Meta-data tags to register with the registry.</param> /// <param name="Callback">Callback method to call when response is returned.</param> /// <param name="State">State object to pass on to the callback method.</param> public void RegisterThing(bool SelfOwned, string NodeId, string SourceId, MetaDataTag[] MetaDataTags, RegistrationEventHandler Callback, object State) { this.RegisterThing(SelfOwned, NodeId, SourceId, string.Empty, MetaDataTags, Callback, State); }
/// <summary> /// Registers a thing in the Thing Registry. Only things that does not have an owner can register with the Thing Registry. /// Things that have an owner should call <see cref="UpdateThing(string, MetaDataTag[], UpdateEventHandler, object)"/> to /// update its meta-data in the Thing Registry, if the meta-data has changed. /// </summary> /// <param name="NodeId">Node ID of thing, if behind a concentrator.</param> /// <param name="MetaDataTags">Meta-data tags to register with the registry.</param> /// <param name="Callback">Callback method to call when response is returned.</param> /// <param name="State">State object to pass on to the callback method.</param> public void RegisterThing(string NodeId, MetaDataTag[] MetaDataTags, RegistrationEventHandler Callback, object State) { this.RegisterThing(false, NodeId, string.Empty, string.Empty, MetaDataTags, Callback, State); }