示例#1
0
        // Called by the sim-bound module
        public HGGroupsServiceRobustConnector(IConfigSource config, IHttpServer server, string configName, IOfflineIMService im, IUserAccountService users) :
            base(config, server, configName)
        {
            if (configName != String.Empty)
            {
                m_ConfigName = configName;
            }

            m_log.DebugFormat("[Groups.RobustHGConnector]: Starting with config name {0}", m_ConfigName);

            string homeURI = Util.GetConfigVarFromSections <string>(config, "HomeURI",
                                                                    new string[] { "Startup", "Hypergrid", m_ConfigName }, string.Empty).ToLowerInvariant();

            if (homeURI == string.Empty)
            {
                throw new Exception(String.Format("[Groups.RobustHGConnector]: please provide the HomeURI [Startup] or in section {0}", m_ConfigName));
            }
            if (!homeURI.EndsWith("/"))
            {
                homeURI += "/";
            }

            IConfig cnf = config.Configs[m_ConfigName];

            if (cnf == null)
            {
                throw new Exception(String.Format("[Groups.RobustHGConnector]: {0} section does not exist", m_ConfigName));
            }

            if (im == null)
            {
                string imDll = cnf.GetString("OfflineIMService", string.Empty);
                if (imDll == string.Empty)
                {
                    throw new Exception(String.Format("[Groups.RobustHGConnector]: please provide OfflineIMService in section {0}", m_ConfigName));
                }

                Object[] args = new Object[] { config };
                im = ServerUtils.LoadPlugin <IOfflineIMService>(imDll, args);
            }

            if (users == null)
            {
                string usersDll = cnf.GetString("UserAccountService", string.Empty);
                if (usersDll == string.Empty)
                {
                    throw new Exception(String.Format("[Groups.RobustHGConnector]: please provide UserAccountService in section {0}", m_ConfigName));
                }

                Object[] args = new Object[] { config };
                users = ServerUtils.LoadPlugin <IUserAccountService>(usersDll, args);
            }

            m_GroupsService = new HGGroupsService(config, im, users, homeURI);

            server.AddStreamHandler(new HGGroupsServicePostHandler(m_GroupsService));
        }
 public HGGroupsServicePostHandler(HGGroupsService service) :
     base("POST", "/hg-groups")
 {
     m_GroupsService = service;
 }
        // Called by the sim-bound module
        public HGGroupsServiceRobustConnector(IConfigSource config, IHttpServer server, string configName, IOfflineIMService im, IUserAccountService users) :
            base(config, server, configName)
        {
            if (configName != String.Empty)
                m_ConfigName = configName;

            m_log.DebugFormat("[Groups.RobustHGConnector]: Starting with config name {0}", m_ConfigName);

            string homeURI = Util.GetConfigVarFromSections<string>(config, "HomeURI", 
                new string[] { "Startup", "Hypergrid", m_ConfigName}, string.Empty); 
            if (homeURI == string.Empty)
                throw new Exception(String.Format("[Groups.RobustHGConnector]: please provide the HomeURI [Startup] or in section {0}", m_ConfigName));

            IConfig cnf = config.Configs[m_ConfigName];
            if (cnf == null)
                throw new Exception(String.Format("[Groups.RobustHGConnector]: {0} section does not exist", m_ConfigName));

            if (im == null)
            {
                string imDll = cnf.GetString("OfflineIMService", string.Empty);
                if (imDll == string.Empty)
                    throw new Exception(String.Format("[Groups.RobustHGConnector]: please provide OfflineIMService in section {0}", m_ConfigName));

                Object[] args = new Object[] { config };
                im = ServerUtils.LoadPlugin<IOfflineIMService>(imDll, args);
            }

            if (users == null)
            {
                string usersDll = cnf.GetString("UserAccountService", string.Empty);
                if (usersDll == string.Empty)
                    throw new Exception(String.Format("[Groups.RobustHGConnector]: please provide UserAccountService in section {0}", m_ConfigName));

                Object[] args = new Object[] { config };
                users = ServerUtils.LoadPlugin<IUserAccountService>(usersDll, args);
            }

            m_GroupsService = new HGGroupsService(config, im, users, homeURI);

            server.AddStreamHandler(new HGGroupsServicePostHandler(m_GroupsService));
        }
 public HGGroupsServicePostHandler(HGGroupsService service) :
     base("POST", "/hg-groups")
 {
     m_GroupsService = service;
 }