private void Claimed(XmppClient Client, XmlElement Element, IqType IqType, string From, string To, string Id) { if (IqType == IqType.Set || IqType == IqType.Get) { try { Client.IqResult(string.Empty, From, Id, "Claimed"); string NodeId = XmlUtilities.GetAttribute(Element, "nodeId", string.Empty); string SourceId = XmlUtilities.GetAttribute(Element, "sourceId", string.Empty); string CacheType = XmlUtilities.GetAttribute(Element, "cacheType", string.Empty); string Owner = XmlUtilities.GetAttribute(Element, "jid", string.Empty); bool Public = XmlUtilities.GetAttribute(Element, "public", false); ClaimedEventArgs e = new ClaimedEventArgs(NodeId, SourceId, CacheType, Owner, Public); ClaimedEventHandler h = this.OnClaimed; if (h != null) { h(this, e); } } catch (Exception ex) { Log.Exception(ex); } } }
private void ClaimedHandler(object Sender, IqEventArgs e) { XmlElement E = e.Query; string OwnerJid = XML.Attribute(E, "jid"); string NodeId = XML.Attribute(E, "id"); string SourceId = XML.Attribute(E, "src"); string Partition = XML.Attribute(E, "pt"); bool Public = XML.Attribute(E, "public", false); ThingReference Node; if (string.IsNullOrEmpty(NodeId) && string.IsNullOrEmpty(SourceId) && string.IsNullOrEmpty(Partition)) { Node = ThingReference.Empty; if (this.client.TryGetExtension(typeof(ProvisioningClient), out IXmppExtension Extension) && Extension is ProvisioningClient ProvisioningClient) { ProvisioningClient.OwnerJid = OwnerJid; } } else { Node = new ThingReference(NodeId, SourceId, Partition); } ClaimedEventArgs e2 = new ClaimedEventArgs(e, Node, OwnerJid, Public); ClaimedEventHandler h = this.Claimed; if (h != null) { try { h(this, e2); } catch (Exception ex) { Log.Critical(ex); } } e.IqResult(string.Empty); }
private void RegisterResponse(XmppClient Client, string Type, XmlNodeList Response, ref StanzaError Error, object State) { // Empty response = OK // Response containing claimed = OK, but already claimed. Update node state and send update command. if (Response != null) { XmlElement E; foreach (XmlNode N in Response) { if (N.LocalName == "claimed" && (E = N as XmlElement) != null) { ClaimedEventHandler h = this.OnClaimed; if (h != null) { try { string Owner = XmlUtilities.GetAttribute(E, "jid", string.Empty); bool Public = XmlUtilities.GetAttribute(E, "public", false); object[] P = (object[])State; string NodeId = (string)P [0]; string CacheType = (string)P [1]; string SourceId = (string)P [2]; ClaimedEventArgs e = new ClaimedEventArgs(NodeId, SourceId, CacheType, Owner, Public); h(this, e); } catch (Exception ex) { Log.Exception(ex); } } } } } }