Example #1
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;
            }
        }
Example #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;
            }
        }