Пример #1
0
 private void AddServerCallback(Scene scene, ServerCallbackImpl serverCallbackImpl)
 {
     m_servercallbacks[scene.RegionInfo.RegionID] = serverCallbackImpl;
 }
        public void Initialise(IConfigSource config)
        {
            if(m_started)
                return;
            m_started = true;

            m_config = config.Configs["MurmurVoice"];

            if (null == m_config)
                {
                m_log.Info("[MurmurVoice] no config found, plugin disabled");
                return;
                }

            if (!m_config.GetBoolean("enabled", false))
                {
                m_log.Info("[MurmurVoice] plugin disabled by configuration");
                return;
                }

            try
                {
                // retrieve configuration variables
                m_murmurd_ice = m_config.GetString("murmur_ice", String.Empty);
                m_murmurd_host = m_config.GetString("murmur_host", String.Empty);
                m_murmurd_exthost = m_config.GetString("murmur_exthost", String.Empty);
                m_murmurd_AgentPass = m_config.GetString("murmur_AgentPass", String.Empty);
                m_murmurd_EstateChannel = m_config.GetString("murmur_EstateChannel", "MyEstate");

                int server_id = m_config.GetInt("murmur_sid", 1);

                // Admin interface required values
                if (String.IsNullOrEmpty(m_murmurd_ice) ||
                    String.IsNullOrEmpty(m_murmurd_host) ||
                    String.IsNullOrEmpty(m_murmurd_AgentPass)
                                                            )
                    {
                    m_log.Error("[MurmurVoice] plugin disabled: incomplete configuration");
                    return;
                    }

                if (String.IsNullOrEmpty(m_murmurd_exthost))
                    m_murmurd_exthost = m_murmurd_host;

                m_murmurd_ice = "Meta:" + m_murmurd_ice;

                Ice.Communicator comm = Ice.Util.initialize();

                bool glacier_enabled = m_config.GetBoolean("glacier", false);

                Glacier2.RouterPrx router = null;
                if(glacier_enabled)
                    {
                    router = RouterPrxHelper.uncheckedCast(comm.stringToProxy(m_config.GetString("glacier_ice", String.Empty)));
                        comm.setDefaultRouter(router);
                    router.createSession(m_config.GetString("glacier_user","admin"),m_config.GetString("glacier_pass","password"));
                    }

                MetaPrx meta = MetaPrxHelper.checkedCast(comm.stringToProxy(m_murmurd_ice));

                // Create the adapter
                comm.getProperties().setProperty("Ice.PrintAdapterReady", "0");
                Ice.ObjectAdapter adapter;
                if(glacier_enabled)
                    {
                    adapter = comm.createObjectAdapterWithRouter("Callback.Client", comm.getDefaultRouter() );
                    }
                else
                    {
                    adapter = comm.createObjectAdapterWithEndpoints("Callback.Client", m_config.GetString("murmur_ice_cb","tcp -h 127.0.0.1"));
                    }
                adapter.activate();

                // Create identity and callback for Metaserver
                Ice.Identity metaCallbackIdent = new Ice.Identity();
                metaCallbackIdent.name = "metaCallback";
                if(router != null)
                    metaCallbackIdent.category = router.getCategoryForClient();
                MetaCallbackPrx meta_callback = MetaCallbackPrxHelper.checkedCast(adapter.add(new MetaCallbackImpl(), metaCallbackIdent ));
                meta.addCallback(meta_callback);

                m_log.InfoFormat("[MurmurVoice] using murmur server ice '{0}'", m_murmurd_ice);

                // create a server and figure out the port name
                Dictionary<string,string> defaults = meta.getDefaultConf();
                ServerPrx server = ServerPrxHelper.checkedCast(meta.getServer(server_id));

                // first check the conf for a port, if not then use server id and default port to find the right one.
                string conf_port = server.getConf("port");
                if(!String.IsNullOrEmpty(conf_port))
                    m_murmurd_port = Convert.ToInt32(conf_port);
                else
                    m_murmurd_port = Convert.ToInt32(defaults["port"])+server_id-1;

                // starts the server and gets a callback
                m_manager = new ServerManager(server, m_murmurd_EstateChannel);

                // Create identity and callback for this current server
                m_callback = new ServerCallbackImpl(server, m_manager);
                Ice.Identity serverCallbackIdent = new Ice.Identity();
                serverCallbackIdent.name = "serverCallback";
                if(router != null)
                    serverCallbackIdent.category = router.getCategoryForClient();
                server.addCallback(ServerCallbackPrxHelper.checkedCast(adapter.add(m_callback, serverCallbackIdent)));

                // Show information on console for debugging purposes
                m_log.InfoFormat("[MurmurVoice] using murmur server '{0}:{1}', sid '{2}' extern host {3}", m_murmurd_host, m_murmurd_port, server_id,m_murmurd_exthost);
                m_log.Info("[MurmurVoice] plugin enabled");
                m_enabled = true;
                }
            catch (Exception e)
                {
                m_log.ErrorFormat("[MurmurVoice] plugin initialization failed: {0}", e.ToString());
                return;
                }
        }
Пример #3
0
 private void AddServerCallback(Scene scene, ServerCallbackImpl serverCallbackImpl)
 {
     m_servercallbacks[scene.RegionInfo.RegionID] = serverCallbackImpl;
 }