Пример #1
0
        /// <summary>
        /// Routine called on a separate thread to load the avatars and objects from the simulators
        /// into LookingGlass.
        /// </summary>
        /// <param name="loadParam"></param>
        private static void LoadSims(Object loadParam)
        {
            LogManager.Log.Log(LogLevel.DCOMM, "LoadWorldObjects: starting to load sim objects");
            try {
                Object[]             loadParams = (Object[])loadParam;
                List <OMV.Simulator> simsToLoad = (List <OMV.Simulator>)loadParams[0];
                OMV.GridClient       netComm    = (OMV.GridClient)loadParams[1];
                CommLLLP             worldComm  = (CommLLLP)loadParams[2];

                OMV.Simulator simm = null;
                try {
                    foreach (OMV.Simulator sim in simsToLoad)
                    {
                        simm = sim;
                        LoadASim(sim, netComm, worldComm);
                    }
                }
                catch (Exception e) {
                    LogManager.Log.Log(LogLevel.DBADERROR, "LoadWorldObjects: exception loading {0}: {1}",
                                       (simm == null ? "NULL" : simm.Name), e.ToString());
                }
            }
            catch (Exception e) {
                LogManager.Log.Log(LogLevel.DBADERROR, "LoadWorldObjects: exception: {0}", e.ToString());
            }
            LogManager.Log.Log(LogLevel.DCOMM, "LoadWorldObjects: completed loading sim objects");
        }
Пример #2
0
        private static void AddObjects(OMV.Simulator sim, OMV.GridClient netComm, CommLLLP worldComm)
        {
            LogManager.Log.Log(LogLevel.DCOMM, "LoadWorldObjects: loading {0} primitives", sim.ObjectsPrimitives.Count);
            List <OMV.Primitive> primsToNew = new List <OpenMetaverse.Primitive>();

            sim.ObjectsPrimitives.ForEach(delegate(OMV.Primitive prim) {
                primsToNew.Add(prim);
            });
            foreach (OMV.Primitive prim in primsToNew)
            {
                // TODO: how can we tell if this prim might be an attachment?
                worldComm.Objects_ObjectUpdate(netComm, new OpenMetaverse.PrimEventArgs(sim, prim, 0, true, false));
            }
        }
Пример #3
0
        private static void AddAvatars(OMV.Simulator sim, OMV.GridClient netComm, CommLLLP worldComm)
        {
            LogManager.Log.Log(LogLevel.DCOMM, "LoadWorldObjects: loading {0} avatars", sim.ObjectsAvatars.Count);
            List <OMV.Avatar> avatarsToNew = new List <OpenMetaverse.Avatar>();

            sim.ObjectsAvatars.ForEach(delegate(OMV.Avatar av) {
                avatarsToNew.Add(av);
            });
            // this happens outside the avatar list lock
            foreach (OMV.Avatar av in avatarsToNew)
            {
                worldComm.Objects_AvatarUpdate(netComm, new OMV.AvatarUpdateEventArgs(sim, av, 0, true));
            }
        }
        // This code follows the form of the Main.cs code in setting up parameters then
        // initialzing and running.
        // Change one, be sure to change the other.
        public void startLGView(Object parm, EventArgs args)
        {
            m_log.Log(LogLevel.DRADEGAST, "startLGView()");
            // force a new default parameter files to Radegast specific ones
            m_lgb.AppParams.AddDefaultParameter("Settings.File", "RadegastLookingGlass.json",
                                                "New default for running under Radecast");
            m_lgb.AppParams.AddDefaultParameter("Settings.Modules", "RadegastModules.json",
                                                "Modules configuration file");

            try {
                m_lgb.ReadConfigurationFile();
            }
            catch (Exception e) {
                throw new Exception("Could not read configuration file: " + e.ToString());
            }

            // log level after all the parameters have been set
            LogManager.CurrentLogLevel = (LogLevel)m_lgb.AppParams.ParamInt("Log.FilterLevel");

            // cause LookingGlass to load all it's modules
            if (!m_lgb.Initialize())
            {
                m_log.Log(LogLevel.DRADEGASTDETAIL, "RadegastMain: Failed LookingGlass initialization. Bailing");
                return;
            }
            m_log.Log(LogLevel.DRADEGASTDETAIL, "RadegastMain: Completed LookingGlass initialization");

            string   radCommName = m_lgb.AppParams.ParamString("Radegast.Comm.Name");
            CommLLLP worldComm   = (CommLLLP)m_lgb.ModManager.Module(radCommName);

            // Set up a bunch of structures and naming
            // Since the user is already logged in and connected to a simulator, this fakes
            // the connection sequence to get the use logged in and connected for the first
            // sim. This is needed to set up the region structures, etc. The contents of that
            // first sim are also copied into LG. The other sims are taken care of by the
            // second call to LoadWorldObjects.
            m_log.Log(LogLevel.DRADEGASTDETAIL, "RadegastMain: Network_OnLogin");
            worldComm.Network_LoginProgress(this, new OMV.LoginProgressEventArgs(OMV.LoginStatus.Success, "Radegast prelogin", ""));
            m_log.Log(LogLevel.DRADEGASTDETAIL, "RadegastMain: Network_OnSimConnected for {0}",
                      RadInstance.Client.Network.CurrentSim.Name);
            worldComm.Network_SimConnected(this, new OMV.SimConnectedEventArgs(RadInstance.Client.Network.CurrentSim));
            worldComm.Network_EventQueueRunning(this, new OMV.EventQueueRunningEventArgs(RadInstance.Client.Network.CurrentSim));

            // if anything was queue for this sim, put them in the world
            LoadWorldObjects.LoadASim(RadInstance.Client.Network.CurrentSim, RadInstance.Client, worldComm);

            // copy the objects that are already in the comm layer into the world
            LoadWorldObjects.Load(RadInstance.Client, worldComm);
        }
        // IModule.AfterAllModulesLoaded
        public virtual bool AfterAllModulesLoaded()
        {
            LogManager.Log.Log(LogLevel.DINIT, ModuleName + ".AfterAllModulesLoaded()");

            try {
                // Find the rest manager and setup to get web requests
                m_restHandler = new RestHandler("/chat", GetHandler, PostHandler);

                // Find the world and connect to same to hear about all the avatars
                String commName = ModuleParams.ParamString(m_moduleName + ".Comm.Name");
                m_comm = (CommLLLP)ModuleManager.Instance.Module(commName);
            }
            catch (Exception e) {
                m_log.Log(LogLevel.DBADERROR, "EXCEPTION CONNECTING TO SERVICES: {0}", e);
                return(false);
            }

            m_comm.GridClient.Self.ChatFromSimulator += new EventHandler <OpenMetaverse.ChatEventArgs>(Self_ChatFromSimulator);

            return(true);
        }
        public override void Start()
        {
            string commName = ModuleParams.ParamString(ModuleName + ".Comm.Name");

            try {
                m_comm = (CommLLLP)ModuleManager.Instance.Module(commName);
            }
            catch (Exception e) {
                m_log.Log(LogLevel.DBADERROR, "CommLLLPRest COULD NOT CONNECT TO COMM MODULE NAMED " + commName);
                m_log.Log(LogLevel.DBADERROR, "CommLLLPRest error = " + e.ToString());
            }
            try {
                m_apiName = ModuleParams.ParamString(ModuleName + ".APIName");

                ParameterSet connParams = m_comm.ConnectionParams;
                m_paramGetHandler = new RestHandler("/" + m_apiName + "/status", ref connParams, false);
                m_actionHandler   = new RestHandler("/" + m_apiName + "/connect", null, ProcessPost);
            }
            catch (Exception e) {
                m_log.Log(LogLevel.DBADERROR, "CommLLLPRest COULD NOT REGISTER REST OPERATION: " + e.ToString());
            }
        }
Пример #7
0
        public static void Load(OMV.GridClient netComm, CommLLLP worldComm)
        {
            LogManager.Log.Log(LogLevel.DCOMM, "LoadWorldObjects: loading existing context");
            List <OMV.Simulator> simsToLoad = new List <OMV.Simulator>();

            lock (netComm.Network.Simulators) {
                foreach (OMV.Simulator sim in netComm.Network.Simulators)
                {
                    if (WeDontKnowAboutThisSimulator(sim, netComm, worldComm))
                    {
                        // tell the world about this simulator
                        LogManager.Log.Log(LogLevel.DCOMMDETAIL, "LoadWorldObjects: adding simulator {0}", sim.Name);
                        worldComm.Network_SimConnected(netComm, new OMV.SimConnectedEventArgs(sim));
                        simsToLoad.Add(sim);
                    }
                }
            }
            Object[] loadParams = { simsToLoad, netComm, worldComm };
            ThreadPool.QueueUserWorkItem(LoadSims, loadParams);
            // ThreadPool.UnsafeQueueUserWorkItem(LoadSims, loadParams);
            LogManager.Log.Log(LogLevel.DCOMM, "LoadWorldObjects: started thread to load sim objects");
        }
Пример #8
0
        // Return 'true' if we don't have this region in our world yet
        private static bool WeDontKnowAboutThisSimulator(OMV.Simulator sim, OMV.GridClient netComm, CommLLLP worldComm)
        {
            LLRegionContext regn = worldComm.FindRegion(delegate(LLRegionContext rgn) {
                return(rgn.Simulator.ID == sim.ID);
            });

            return(regn == null);
        }
Пример #9
0
 public static void LoadASim(OMV.Simulator sim, OMV.GridClient netComm, CommLLLP worldComm)
 {
     LogManager.Log.Log(LogLevel.DCOMM, "LoadWorldObjects: loading avatars and objects for sim {0}", sim.Name);
     AddAvatars(sim, netComm, worldComm);
     AddObjects(sim, netComm, worldComm);
 }