[Test] public void Test_Item() { AgentsIQ aiq = new AgentsIQ(doc); AgentsQuery q = (AgentsQuery)aiq.Query; Agent a = q.AddAgent(); a.JID = new JID("*****@*****.**"); Assert.AreEqual("<iq id=\"" + aiq.ID + "\" type=\"get\"><query xmlns=\"Jabber:iq:agents\">" + "<agent jid=\"[email protected]\" /></query></iq>", aiq.ToString()); }
[Test] public void Test_GetItems() { AgentsIQ aiq = new AgentsIQ(doc); AgentsQuery r = (AgentsQuery)aiq.Query; Agent a = r.AddAgent(); a.JID = new JID("*****@*****.**"); a = r.AddAgent(); a.JID = new JID("*****@*****.**"); Agent[] agents = r.GetAgents(); Assert.AreEqual(agents.Length, 2); Assert.AreEqual(agents[0].JID, "*****@*****.**"); Assert.AreEqual(agents[1].JID, "*****@*****.**"); }
[Test] public void Test_Transport() { AgentsIQ aiq = new AgentsIQ(doc); aiq.Type = IQType.result; AgentsQuery r = (AgentsQuery)aiq.Query; Agent a = r.AddAgent(); a.JID = new JID("*****@*****.**"); a.Transport = true; Assert.AreEqual(a.Transport, true); Assert.AreEqual("<iq id=\"" + aiq.ID + "\" type=\"result\"><query xmlns=\"Jabber:iq:agents\">" + "<agent jid=\"[email protected]\"><transport /></agent></query></iq>", aiq.ToString()); a.Transport = false; Assert.AreEqual(a.Transport, false); a.Groupchat = true; Assert.AreEqual(a.Groupchat, true); Assert.AreEqual("<iq id=\"" + aiq.ID + "\" type=\"result\"><query xmlns=\"Jabber:iq:agents\">" + "<agent jid=\"[email protected]\"><groupchat /></agent></query></iq>", aiq.ToString()); }
public void Test_Create() { AgentsQuery r = new AgentsQuery(doc); Assert.AreEqual("<query xmlns=\"jabber:iq:agents\" />", r.ToString()); }
[Test] public void Test_Create() { AgentsQuery r = new AgentsQuery(doc); Assert.AreEqual("<query xmlns=\"Jabber:iq:agents\" />", r.ToString()); }
private void GotAgents(object sender, IQ iq, object onode) { DiscoNode dn = onode as DiscoNode; Debug.Assert(dn != null); if (iq.Type != IQType.result) { dn.AddItems(this, null); return; } AgentsQuery aq = iq.Query as AgentsQuery; if (aq == null) { dn.AddItems(this, null); return; } if (dn.Children == null) { dn.Children = new Set(); } foreach (Agent agent in aq.GetAgents()) { DiscoItem di = new DiscoItem(m_stream.Document); di.Jid = agent.JID; di.Named = agent.AgentName; DiscoNode child = dn.AddItem(this, di); if (child.Features == null) { child.Features = new StringSet(); } if (child.Identity == null) { child.Identity = new Set(); } Ident id = new Ident(); id.Name = agent.Description; switch (agent.Service) { case "groupchat": id.Category = "conference"; id.Type = "text"; child.Identity.Add(id); break; case "jud": id.Category = "directory"; id.Type = "user"; child.Identity.Add(id); break; case null: case "": break; default: // guess this is a transport id.Category = "gateway"; id.Type = agent.Service; child.Identity.Add(id); break; } if (agent.Register) { child.Features.Add(URI.REGISTER); } if (agent.Search) { child.Features.Add(URI.SEARCH); } if (agent.Groupchat) { child.Features.Add(URI.MUC); } if (agent.Transport) { if (id.Category != "gateway") { Ident tid = new Ident(); tid.Name = id.Name; tid.Category = "gateway"; child.Identity.Add(tid); } } foreach (XmlElement ns in agent.GetElementsByTagName("ns")) { child.Features.Add(ns.InnerText); } child.AddItems(this, null); child.AddIdentities(null); child.AddFeatures((StringSet)null); } dn.AddItems(this, null); dn.AddIdentities(null); dn.AddFeatures((StringSet)null); }
public JsonResult GetAgents(AgentsQuery q) { var agents = _agentsRepository.GetPage(q.PageIndex, q.PageSize, null, null); return(Json(agents)); }