Exemplo n.º 1
0
        public void Presence_001()
        {
            PresenceServicesConnector m_Connector = new PresenceServicesConnector(DemonServer.Address);

            UUID user1 = UUID.Random();
            UUID session1 = UUID.Random();
            UUID region1 = UUID.Random();

            bool success = m_Connector.LoginAgent(user1.ToString(), session1, UUID.Zero);
            Assert.AreEqual(success, true, "Failed to add user session");

            PresenceInfo pinfo = m_Connector.GetAgent(session1);
            Assert.AreNotEqual(pinfo, null, "Unable to retrieve session");
            Assert.AreEqual(pinfo.UserID, user1.ToString(), "Retrieved session does not match expected userID");
            Assert.AreNotEqual(pinfo.RegionID, region1, "Retrieved session is unexpectedly in region");

            success = m_Connector.ReportAgent(session1, region1);
            Assert.AreEqual(success, true, "Failed to report session in region 1");

            pinfo = m_Connector.GetAgent(session1);
            Assert.AreNotEqual(pinfo, null, "Unable to session presence");
            Assert.AreEqual(pinfo.UserID, user1.ToString(), "Retrieved session does not match expected userID");
            Assert.AreEqual(pinfo.RegionID, region1, "Retrieved session is not in expected region");

            success = m_Connector.LogoutAgent(session1);
            Assert.AreEqual(success, true, "Failed to remove session");

            pinfo = m_Connector.GetAgent(session1);
            Assert.AreEqual(pinfo, null, "Session is still there, even though it shouldn't");

            success = m_Connector.ReportAgent(session1, UUID.Random());
            Assert.AreEqual(success, false, "Remove non-existing session should fail");
        }
        public void Initialise(IConfigSource source)
        {
            IConfig moduleConfig = source.Configs["Modules"];
            if (moduleConfig != null)
            {
                string name = moduleConfig.GetString("PresenceServices", "");
                if (name == Name)
                {
                    m_PresenceService = new PresenceServicesConnector(source);

                    m_Enabled = true;

                    m_PresenceDetector = new PresenceDetector(this);

                    m_log.Info("[REMOTE PRESENCE CONNECTOR]: Remote presence enabled");
                }
            }
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            ConsoleAppender consoleAppender = new ConsoleAppender();
            consoleAppender.Layout =
                new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
            log4net.Config.BasicConfigurator.Configure(consoleAppender);

            string serverURI = "http://127.0.0.1:8003";
            PresenceServicesConnector m_Connector = new PresenceServicesConnector(serverURI);

            UUID user1 = UUID.Random();
            UUID session1 = UUID.Random();
            UUID region1 = UUID.Random();

            bool success = m_Connector.LoginAgent(user1.ToString(), session1, UUID.Zero);
            if (success)
                m_log.InfoFormat("[PRESENCE CLIENT]: Successfully logged in user {0} with session {1}", user1, session1);
            else
                m_log.InfoFormat("[PRESENCE CLIENT]: failed to login user {0}", user1);

            System.Console.WriteLine("\n");

            PresenceInfo pinfo = m_Connector.GetAgent(session1);
            if (pinfo == null)
                m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0}", user1);
            else
                m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; regionID={1}", 
                    pinfo.UserID, pinfo.RegionID);

            System.Console.WriteLine("\n");
            success = m_Connector.ReportAgent(session1, region1);
            if (success)
                m_log.InfoFormat("[PRESENCE CLIENT]: Successfully reported session {0} in region {1}", user1, region1);
            else
                m_log.InfoFormat("[PRESENCE CLIENT]: failed to report session {0}", session1);
            pinfo = m_Connector.GetAgent(session1);
            if (pinfo == null)
                m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for second time", user1);
            else
                m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; regionID={2}",
                    pinfo.UserID, pinfo.RegionID);

            System.Console.WriteLine("\n");
            success = m_Connector.LogoutAgent(session1);
            if (success)
                m_log.InfoFormat("[PRESENCE CLIENT]: Successfully logged out user {0}", user1);
            else
                m_log.InfoFormat("[PRESENCE CLIENT]: failed to logout user {0}", user1);
            pinfo = m_Connector.GetAgent(session1);
            if (pinfo == null)
                m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for fourth time", user1);
            else
                m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; regionID={1}",
                    pinfo.UserID, pinfo.RegionID);

            System.Console.WriteLine("\n");
            success = m_Connector.ReportAgent(session1, UUID.Random());
            if (success)
                m_log.InfoFormat("[PRESENCE CLIENT]: Report agent succeeded, but this is wrong");
            else
                m_log.InfoFormat("[PRESENCE CLIENT]: failed to report agent, as it should because user is not logged in");

        }