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");
 }
 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));
     }
 }
 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));
     }
 }
 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);
 }
 // 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);
 }
        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
        // 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;
        }