Esempio n. 1
0
        /// <summary>
        /// 开启服务
        /// </summary>
        /// <param name="appPath">程序路径</param>
        public static void StartService()
        {
            //读取配置
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(DataCenter.GetAppPath() + "\\hostinfo.xml");
            XmlNode root = xmlDoc.DocumentElement;

            foreach (XmlNode node in root.ChildNodes)
            {
                String name  = node.Name.ToLower();
                String value = node.InnerText;
                if (name == "clearcache")
                {
                    m_hostInfo.m_clearCache = value == "1";
                }
                else if (name == "defaulthost")
                {
                    if (value.Length > 0)
                    {
                        String[] strs = value.Split(new String[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
                        m_hostInfo.m_defaultHost = strs[0];
                        m_hostInfo.m_defaultPort = CStr.ConvertStrToInt(strs[1]);
                    }
                }
                else if (name == "isfull")
                {
                    m_hostInfo.m_isFull = value == "1";
                }
                else if (name == "localhost")
                {
                    if (value.Length > 0)
                    {
                        String[] strs = value.Split(new String[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
                        m_hostInfo.m_localHost = strs[0];
                        m_hostInfo.m_localPort = CStr.ConvertStrToInt(strs[1]);
                    }
                }
            }
            if (m_hostInfo.m_clearCache)
            {
                CFileA.RemoveFile(DataCenter.GetAppPath() + "\\usercookies.db");
            }
            m_userCookieService = new UserCookieService();
            Random rd = new Random();

            m_isFull = m_hostInfo.m_isFull;
            String[] servers = new String[] { };
            OwLibSV.BaseService.AddService(m_serverChatService);
            if (m_isFull)
            {
                OwLibSV.BaseService.StartServer(0, m_serverChatService.Port);
            }
        }