コード例 #1
0
        internal static void PresManager_OnPrimarySessionChange(object sender, jabber.JID bare)
        {
            if (AllPlayers.ContainsKey(bare.User))
            {
                ChatPlayerItem Player = AllPlayers[bare.User];
                Player.IsOnline = false;
                UpdatePlayers   = true;
                jabber.protocol.client.Presence[] s = PresManager.GetAll(bare);
                if (s.Length == 0)
                {
                    return;
                }
                string Presence = s[0].Status;
                if (Presence == null)
                {
                    return;
                }
                Player          = ParsePresence(Presence);
                Player.IsOnline = true;

                if (String.IsNullOrWhiteSpace(Player.Status))
                {
                    Player.Status = "Online";
                }
            }
        }
コード例 #2
0
        public void TestNewPrimaryAlgorithm()
        {
            PresenceManager pp = new PresenceManager();

            Presence pres = new Presence(doc);

            pres.From        = baz;
            pres.IntPriority = 1;
            pp.AddPresence(pres);
            Assert.AreEqual(1, pp[bare].IntPriority);
            Assert.AreEqual(baz, pp[bare].From);

            pres             = new Presence(doc);
            pres.From        = boo;
            pres.IntPriority = 2;
            pp.AddPresence(pres);
            // duh.
            Assert.AreEqual(2, pp[bare].IntPriority);
            Assert.AreEqual(boo, pp[bare].From);

            pres             = new Presence(doc);
            pres.From        = boo;
            pres.IntPriority = 0;
            pp.AddPresence(pres);
            Assert.AreEqual(1, pp[bare].IntPriority);
            Assert.AreEqual(baz, pp[bare].From); // ooo

            pres      = new Presence(doc);
            pres.From = boo;
            pres.Type = PresenceType.unavailable;
            pp.AddPresence(pres);
            Assert.AreEqual(1, pp[bare].IntPriority);
            Assert.AreEqual(baz, pp[bare].From);

            pres             = new Presence(doc);
            pres.From        = baz;
            pres.IntPriority = -1;
            pp.AddPresence(pres);
            Assert.AreEqual(null, pp[bare]);

            pres      = new Presence(doc);
            pres.From = baz;
            pres.Type = PresenceType.unavailable;
            pp.AddPresence(pres);
            Assert.AreEqual(0, pp.GetAll(bare).Length);
        }
コード例 #3
0
        public void TestGetAll()
        {
            PresenceManager pp = new PresenceManager();

            Presence pres = new Presence(doc);

            pres.From = baz;
            pp.AddPresence(pres);

            pres      = new Presence(doc);
            pres.From = boo;
            pp.AddPresence(pres);

            Presence[] pa = pp.GetAll(bare);
            Assert.AreEqual(2, pa.Length);
            Assert.AreEqual(pa[0].GetType(), typeof(Presence));
        }