コード例 #1
0
        public void Initialize(IScene scene)
        {
            try
            {
                if (!m_enabled)
                {
                    return;
                }

                IMurmurService service = scene.RequestModuleInterface <IMurmurService>();
                if (service == null)
                {
                    return;
                }

                MurmurConfig config = service.GetConfiguration(scene.RegionInfo.RegionName);
                if (config == null)
                {
                    return;
                }

                bool justStarted = false;
                if (!m_started)
                {
                    justStarted = true;
                    m_started   = true;

                    // retrieve configuration variables
                    m_murmurd_host   = config.MurmurHost;
                    m_server_version = config.ServerVersion;
                    //Fix the callback URL, its our IP, so we deal with it
                    IConfig m_config = m_source.Configs["MurmurService"];
                    if (m_config != null)
                    {
                        config.IceCB = m_config.GetString("murmur_ice_cb", "tcp -h 127.0.0.1");
                    }

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

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

                    if (config.GlacierEnabled)
                    {
                        router = RouterPrxHelper.uncheckedCast(comm.stringToProxy(config.GlacierIce));
                        comm.setDefaultRouter(router);
                        router.createSession(config.GlacierUser, config.GlacierPass);
                    }

                    MetaPrx meta = MetaPrxHelper.checkedCast(comm.stringToProxy(config.MetaIce));

                    // Create the adapter
                    comm.getProperties().setProperty("Ice.PrintAdapterReady", "0");
                    if (config.GlacierEnabled)
                    {
                        adapter = comm.createObjectAdapterWithRouter("Callback.Client", comm.getDefaultRouter());
                    }
                    else
                    {
                        adapter = comm.createObjectAdapterWithEndpoints("Callback.Client", config.IceCB);
                    }
                    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}'", config.MetaIce);

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

                    // start thread to ping glacier2 router and/or determine if con$
                    m_keepalive = new KeepAlive(m_server);
                    ThreadStart ka_d = new ThreadStart(m_keepalive.StartPinging);
                    m_keepalive_t = new Thread(ka_d);
                    m_keepalive_t.Start();

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

                    try
                    {
                        m_server.start();
                    }
                    catch
                    {
                    }
                }

                // starts the server and gets a callback
                ServerManager manager = new ServerManager(m_server, config.ChannelName);

                // Create identity and callback for this current server
                AddServerCallback(scene, new ServerCallbackImpl(manager));
                AddServerManager(scene, manager);

                if (justStarted)
                {
                    Ice.Identity serverCallbackIdent = new Ice.Identity();
                    serverCallbackIdent.name = "serverCallback";
                    if (router != null)
                    {
                        serverCallbackIdent.category = router.getCategoryForClient();
                    }

                    m_server.addCallback(ServerCallbackPrxHelper.checkedCast(adapter.add(GetServerCallback(scene), serverCallbackIdent)));
                }

                // Show information on console for debugging purposes
                m_log.InfoFormat("[MurmurVoice] using murmur server '{0}:{1}', sid '{2}'", m_murmurd_host, m_murmurd_port, config.ServerID);
                m_log.Info("[MurmurVoice] plugin enabled");
                m_enabled = true;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[MurmurVoice] plugin initialization failed: {0}", e.ToString());
                return;
            }
        }
コード例 #2
0
        public void Initialize(Scene scene)
        {
            try
            {
                if (!m_enabled)
                {
                    return;
                }

                if (!m_started)
                {
                    m_started = true;

                    scene.AddCommand(this, "mumble report", "mumble report",
                                     "Returns mumble report", MumbleReport);

                    scene.AddCommand(this, "mumble unregister", "mumble unregister <userid>",
                                     "Unregister User by userid", UnregisterUser);

                    scene.AddCommand(this, "mumble remove", "mumble remove <UUID>",
                                     "Remove Agent by UUID", RemoveAgent);

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

                    if (m_glacier_enabled)
                    {
                        m_router = RouterPrxHelper.uncheckedCast(comm.stringToProxy(m_glacier_ice));
                        comm.setDefaultRouter(m_router);
                        m_router.createSession(m_glacier_user, m_glacier_pass);
                    }

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

                    // Create the adapter
                    comm.getProperties().setProperty("Ice.PrintAdapterReady", "0");
                    if (m_glacier_enabled)
                    {
                        m_adapter = comm.createObjectAdapterWithRouter("Callback.Client", comm.getDefaultRouter());
                    }
                    else
                    {
                        m_adapter = comm.createObjectAdapterWithEndpoints("Callback.Client", m_murmur_ice_cb);
                    }
                    m_adapter.activate();

                    // Create identity and callback for Metaserver
                    Ice.Identity metaCallbackIdent = new Ice.Identity();
                    metaCallbackIdent.name = "metaCallback";
                    if (m_router != null)
                    {
                        metaCallbackIdent.category = m_router.getCategoryForClient();
                    }
                    MetaCallbackPrx meta_callback = MetaCallbackPrxHelper.checkedCast(m_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();
                    m_server = ServerPrxHelper.checkedCast(meta.getServer(m_server_id));

                    // start thread to ping glacier2 router and/or determine if con$
                    m_keepalive = new KeepAlive(m_server);
                    ThreadStart ka_d = new ThreadStart(m_keepalive.StartPinging);
                    m_keepalive_t = new Thread(ka_d);
                    m_keepalive_t.Start();

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

                    try
                    {
                        m_server.start();
                    }
                    catch
                    {
                    }

                    m_log.Info("[MurmurVoice] started");
                }

                // starts the server and gets a callback
                ServerManager manager = new ServerManager(m_server, m_channel_name);

                // Create identity and callback for this current server
                AddServerCallback(scene, new ServerCallbackImpl(manager));
                AddServerManager(scene, manager);

                Ice.Identity serverCallbackIdent = new Ice.Identity();
                serverCallbackIdent.name = "serverCallback_" + scene.RegionInfo.RegionName.Replace(" ", "_");
                if (m_router != null)
                {
                    serverCallbackIdent.category = m_router.getCategoryForClient();
                }

                m_server.addCallback(ServerCallbackPrxHelper.checkedCast(m_adapter.add(GetServerCallback(scene), serverCallbackIdent)));

                // Show information on console for debugging purposes
                m_log.InfoFormat("[MurmurVoice] using murmur server '{0}:{1}', sid '{2}'", m_murmurd_host, m_murmurd_port, m_server_id);
                m_log.Info("[MurmurVoice] plugin enabled");
                m_enabled = true;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[MurmurVoice] plugin initialization failed: {0}", e.ToString());
                return;
            }
        }