Ejemplo n.º 1
0
        public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db)
        {
            m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType());

            m_Database    = db;
            m_GridService = gridService;

            IConfig gridConfig = config.Configs["GridService"];

            if (gridConfig != null)
            {
                string assetService = gridConfig.GetString("AssetService", string.Empty);

                Object[] args = new Object[] { config };

                if (assetService != string.Empty)
                {
                    m_AssetService = ServerUtils.LoadPlugin <IAssetService>(assetService, args);
                }

                string scope = gridConfig.GetString("ScopeID", string.Empty);
                if (scope != string.Empty)
                {
                    UUID.TryParse(scope, out m_ScopeID);
                }

                m_Check4096 = gridConfig.GetBoolean("Check4096", true);

                m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);

                m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services...");
            }

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
                                                         "Link a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region",
                                                         "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
                                                         "Unlink a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
                                                         "Set local coordinate to map HG regions to", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks <cr>",
                                                         "List the HG regions", HandleShow);
            }
        }
        public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db)
        {
            IConfig gridConfig = config.Configs["GridService"];

            if (gridConfig == null)
            {
                return;
            }

            if (!gridConfig.GetBoolean("HypergridLinker", false))
            {
                return;
            }

            m_Database    = db;
            m_GridService = gridService;
            m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType());

            string assetService = gridConfig.GetString("AssetService", string.Empty);

            Object[] args = new Object[] { config };

            if (assetService != string.Empty)
            {
                m_AssetService = ServerUtils.LoadPlugin <IAssetService>(assetService, args);
            }

            string scope = gridConfig.GetString("ScopeID", string.Empty);

            if (scope != string.Empty)
            {
                UUID.TryParse(scope, out m_ScopeID);
            }

//                m_Check4096 = gridConfig.GetBoolean("Check4096", true);

            m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles");

            m_ThisGatekeeper = Util.GetConfigVarFromSections <string>(config, "GatekeeperURI",
                                                                      new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);
            // Legacy. Remove soon!
            m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper);
            try
            {
                m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper);
            }
            catch
            {
                m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper);
            }

            m_ThisGatekeeper = m_ThisGatekeeperURI.AbsoluteUri;
            if (m_ThisGatekeeperURI.Port == 80)
            {
                m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) + ":80/";
            }
            else if (m_ThisGatekeeperURI.Port == 443)
            {
                m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) + ":443/";
            }

            m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);

            m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");

            if (!string.IsNullOrEmpty(m_MapTileDirectory))
            {
                try
                {
                    Directory.CreateDirectory(m_MapTileDirectory);
                }
                catch (Exception e)
                {
                    m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e);
                    m_MapTileDirectory = string.Empty;
                }
            }

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]",
                                                         "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]",
                                                         "Link a hypergrid region (deprecated)", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region",
                                                         "unlink-region <local name>",
                                                         "Unlink a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [<x> <y>]",
                                                         "Set local coordinate to map HG regions to", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks",
                                                         "List the HG regions", HandleShow);
            }
        }
Ejemplo n.º 3
0
        public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db)
        {
            m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType());

            m_Database = db;
            m_GridService = gridService;

            IConfig gridConfig = config.Configs["GridService"];
            if (gridConfig != null)
            {
                string assetService = gridConfig.GetString("AssetService", string.Empty);

                Object[] args = new Object[] { config };

                if (assetService != string.Empty)
                    m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args);

                string scope = gridConfig.GetString("ScopeID", string.Empty);
                if (scope != string.Empty)
                    UUID.TryParse(scope, out m_ScopeID);

                m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);

                m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services...");
            }

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region",
                    "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
                    "Link a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region",
                    "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
                    "Unlink a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
                    "Set local coordinate to map HG regions to", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks <cr>",
                    "List the HG regions", HandleShow);
            }
        }
Ejemplo n.º 4
0
        public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db)
        {
            IConfig gridConfig = config.Configs["GridService"];

            if (gridConfig == null)
            {
                return;
            }

            if (!gridConfig.GetBoolean("HypergridLinker", false))
            {
                return;
            }

            m_Database    = db;
            m_GridService = gridService;
            m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType());

            string assetService = gridConfig.GetString("AssetService", string.Empty);

            Object[] args = new Object[] { config };

            if (assetService != string.Empty)
            {
                m_AssetService = ServerUtils.LoadPlugin <IAssetService>(assetService, args);
            }

            string scope = gridConfig.GetString("ScopeID", string.Empty);

            if (scope != string.Empty)
            {
                UUID.TryParse(scope, out m_ScopeID);
            }

//                m_Check4096 = gridConfig.GetBoolean("Check4096", true);

            m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles");

            m_ThisGridInfo = new GridInfo(config);
            if (!m_ThisGridInfo.HasHGConfig)
            {
                throw new Exception("missing HyperGrid configuration");
            }

            m_log.DebugFormat("[HYPERGRID LINKER]: Local Gatekeeper: {0}", m_ThisGridInfo.GateKeeperURL);

            m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);

            m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");

            if (!string.IsNullOrEmpty(m_MapTileDirectory))
            {
                try
                {
                    Directory.CreateDirectory(m_MapTileDirectory);
                }
                catch (Exception e)
                {
                    m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e);
                    m_MapTileDirectory = string.Empty;
                }
            }

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]",
                                                         "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]",
                                                         "Link a hypergrid region (deprecated)", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region",
                                                         "unlink-region <local name>",
                                                         "Unlink a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [<x> <y>]",
                                                         "Set local coordinate to map HG regions to", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks",
                                                         "List the HG regions", HandleShow);
            }
        }
Ejemplo n.º 5
0
        public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db)
        {
            IConfig gridConfig = config.Configs["GridService"];

            if (gridConfig == null)
            {
                return;
            }

            if (!gridConfig.GetBoolean("HypergridLinker", false))
            {
                return;
            }

            m_Database    = db;
            m_GridService = gridService;
            m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType());

            string assetService = gridConfig.GetString("AssetService", string.Empty);

            Object[] args = new Object[] { config };

            if (assetService != string.Empty)
            {
                m_AssetService = ServerUtils.LoadPlugin <IAssetService>(assetService, args);
            }

            string scope = gridConfig.GetString("ScopeID", string.Empty);

            if (scope != string.Empty)
            {
                UUID.TryParse(scope, out m_ScopeID);
            }

//                m_Check4096 = gridConfig.GetBoolean("Check4096", true);

            m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles");

            m_ThisGatekeeperURI = Util.GetConfigVarFromSections <string>(config, "GatekeeperURI",
                                                                         new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);
            m_ThisGatekeeperURI = gridConfig.GetString("Gatekeeper", m_ThisGatekeeperURI);

            if (!Util.checkServiceURI(m_ThisGatekeeperURI, out m_ThisGatekeeperURI, out m_ThisGatekeeperHost, out m_ThisGateKeeperIP))
            {
                m_log.ErrorFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeperURI);
                throw new Exception("Failed to resolve gatekeeper external IP, please check GatekeeperURI configuration");
            }

            string gatekeeperURIAlias = Util.GetConfigVarFromSections <string>(config, "GatekeeperURIAlias",
                                                                               new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);

            if (!string.IsNullOrWhiteSpace(gatekeeperURIAlias))
            {
                string[] alias = gatekeeperURIAlias.Split(',');
                for (int i = 0; i < alias.Length; ++i)
                {
                    if (!string.IsNullOrWhiteSpace(alias[i]))
                    {
                        m_ThisGateKeeperAlias.Add(alias[i].Trim().ToLower());
                    }
                }
            }

            m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);

            m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");

            if (!string.IsNullOrEmpty(m_MapTileDirectory))
            {
                try
                {
                    Directory.CreateDirectory(m_MapTileDirectory);
                }
                catch (Exception e)
                {
                    m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e);
                    m_MapTileDirectory = string.Empty;
                }
            }

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]",
                                                         "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]",
                                                         "Link a hypergrid region (deprecated)", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region",
                                                         "unlink-region <local name>",
                                                         "Unlink a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [<x> <y>]",
                                                         "Set local coordinate to map HG regions to", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks",
                                                         "List the HG regions", HandleShow);
            }
        }