public void Test_Available() { Presence p = new Presence(doc); Assert.AreEqual(PresenceType.available, p.Type); Assert.AreEqual("", p.GetAttribute("type")); p.Type = PresenceType.unavailable; Assert.AreEqual(PresenceType.unavailable, p.Type); Assert.AreEqual("unavailable", p.GetAttribute("type")); p.Type = PresenceType.available; Assert.AreEqual(PresenceType.available, p.Type); Assert.AreEqual("", p.GetAttribute("type")); }
[Test] public void Test_Available() { Presence p = new Presence(doc); Assert.AreEqual(PresenceType.available, p.Type); Assert.AreEqual("", p.GetAttribute("type")); p.Type = PresenceType.unavailable; Assert.AreEqual(PresenceType.unavailable, p.Type); Assert.AreEqual("unavailable", p.GetAttribute("type")); p.Type = PresenceType.available; Assert.AreEqual(PresenceType.available, p.Type); Assert.AreEqual("", p.GetAttribute("type")); }
public void XmppConnectOnOnPresence(object sender, Presence pres) { try { if (pres.GetAttribute("name") == "Facebook User") { return; } Core.Presences.Add(pres); try { var chatItem = new ChatPlayerItem { Group = pres.GetAttribute("group"), IsOnline = true, Jid = new Jid(pres.GetAttribute("jid")), Messages = new List <string>(), Username = pres.GetAttribute("name") }; Core.AllPlayers.Add(pres.GetAttribute("name"), chatItem); } catch { var item = Core.AllPlayers[pres.GetAttribute("name")]; Core.AllPlayers.Remove(pres.GetAttribute("name")); item.IsOnline = true; Core.AllPlayers.Add(pres.GetAttribute("name"), item); } } catch { //MessageBox.Show(ex.ToString()); } }
/// <summary> /// Adds a new available or unavailable presence packet to the database. /// </summary> /// <param name="p">Presence stanza to add.</param> public void AddPresence(Presence p) { // can't use .From, since that will cause a JID parse. Debug.Assert(p.GetAttribute("from") != "", "Do not call AddPresence by hand. I can tell you are doing that because you didn't put a from address on your presence packet, and all presences from the server have a from address."); GotPresence(this, p); }