private HandlerResult ReceivedDiscoRequest(Account account, Message message) { if (message.SubType == MessageSubType.Get && message.Node.FirstChild != null && message.Node.FirstChild.Name == "query" && message.Node.FirstChild.GetAttribute("xmlns") == Namespace.DiscoInfo) { string from = message.Node.GetAttribute("from"); string id = message.Node.GetAttribute("id"); Console.WriteLine("Received disco info request from " + from); Message resultMessage = new Message(from, MessageType.Iq, MessageSubType.Result); resultMessage.Node.SetAttribute("id", id); MessageNode queryNode = resultMessage.Node.AddChild("query", null); queryNode.SetAttribute("xmlns", Namespace.DiscoInfo); foreach (Identity identity in m_Account.Identities) { MessageNode identityNode = queryNode.AddChild("identity", null); identityNode.SetAttribute("category", identity.Category.ToString()); identityNode.SetAttribute("type", identity.Type.ToString()); identityNode.SetAttribute("name", identity.Name); } foreach (string featureName in m_Account.Features.SelectMany(x => x.FeatureNames)) { MessageNode featureNode = queryNode.AddChild("feature", null); featureNode.SetAttribute("var", featureName); } account.Send(resultMessage); } return(HandlerResult.AllowMoreHandlers); }
public void GetInfo(Jid entity, string node, MessageHandlerFunc callback) { Message m = new Message(entity.ToString(), MessageType.Iq, MessageSubType.Get); MessageNode queryNode = m.Node.AddChild("query", null); queryNode.SetAttribute("xmlns", Namespace.DiscoInfo); queryNode.SetAttribute("node", node); m_Account.Send(m, callback); }
public void SetData(string xml, MessageHandlerFunc callback) { Message message = new Message(null, MessageType.Iq, MessageSubType.Set); MessageNode query = message.Node.AddChild("query", xml); query.SetAttribute("xmlns", Namespace.PrivateXmlStorage); m_Account.Send(message, callback); }
public void GetData(string elementName, string elementNamespace, MessageHandlerFunc callback) { Message message = new Message(null, MessageType.Iq, MessageSubType.Get); MessageNode query = message.Node.AddChild("query", null); query.SetAttribute("xmlns", Namespace.PrivateXmlStorage); MessageNode child = query.AddChild(elementName, null); child.SetAttribute("xmlns", elementNamespace); m_Account.Send(message, callback); }