Ejemplo n.º 1
0
        public static void update2PassKey()
        {
            //需要从数据库中获取
            Func <object> hand = delegate()
            {
                List <string> list = new List <string>();
                list.Add("gameid");
                list.Add("url");
                list.Add("Platformid");
                list.Add("Clientversion");
                list.Add("Payway");
                list.Add("status");
                list.Add("PassKey");
                Dictionary <int, Dictionary <string, string> > SQLDBServerInfo;
                bool dbselectres = DBOper.select("SELECT * FROM WebServerInfo", ref list, out SQLDBServerInfo);
                if (dbselectres == false)
                {
                    return(null);
                }
                else if (SQLDBServerInfo.Count < 1)
                {
                    return(null);
                }
                else
                {
                    return(SQLDBServerInfo);
                }
            };
            Dictionary <int, Dictionary <string, string> > WebServerInfo = (Dictionary <int, Dictionary <string, string> >)InstanceData.get("WebServerInfo", hand);

            if (WebServerInfo == null)
            {
                return;
            }
            string key = WebServerInfo[0]["PassKey"];

            if (key != null && key.Length > 255)
            {
                lock (bip)
                {
                    bip = System.Text.Encoding.Default.GetBytes(key);
                }
            }
        }
Ejemplo n.º 2
0
        static SJSocket()
        {
            LogHandler = delegate(string s)
            {
                LoginFile.Write(s);
            };
            Func <object> NilHandle = delegate()
            {
                List <string> list = new List <string>();
                list.Add("gameid");
                list.Add("ServerIp");
                list.Add("ServerProt");
                list.Add("ServerName");
                Dictionary <int, Dictionary <string, string> > SQLDBServerInfo;
                bool dbselectres = DBOper.select("SELECT top 1 * FROM DBServerInfo", ref list, out SQLDBServerInfo);
                if (dbselectres == false)
                {
                    return(null);
                }
                else if (SQLDBServerInfo.Count < 1)
                {
                    return(null);
                }
                else
                {
                    return(SQLDBServerInfo[0]);
                }
            };
            Object ODBServerInfo = Tools.InstanceData.get("DBServerInfo", NilHandle);

            if (null == ODBServerInfo)
            {
                throw new Exception("不能获取到ip和port");
            }
            Dictionary <string, string> DBServerInfo = ODBServerInfo as Dictionary <string, string>;

            DefaultIp   = DBServerInfo["ServerIp"];
            DefaultPort = Convert.ToInt32(DBServerInfo["ServerProt"]);
        }