Exemple #1
0
        /// <summary>
        /// 处理消息
        /// </summary>
        private void ProcessSocketMsg()
        {
            string sScoketText;
            string sData = string.Empty;
            string sCode = string.Empty;
            string sBody;
            int    nIdent;
            int    nC;

            nC          = 0;
            sScoketText = m_sSockMsg;
            while ((sScoketText.IndexOf(')') > 0))
            {
                sScoketText = HUtil32.ArrestStringEx(sScoketText, "(", ")", ref sData);
                if (sData == string.Empty)
                {
                    break;
                }
                sBody  = HUtil32.GetValidStr3(sData, ref sCode, new string[] { "/" });
                nIdent = HUtil32.Str_ToInt(sCode, 0);
                switch (nIdent)
                {
                case Common.SS_OPENSESSION:    // 100
                    ProcessAddSession(sBody);
                    break;

                case Common.SS_CLOSESESSION:    // 101
                    ProcessDelSession(sBody);
                    break;

                case Common.SS_KEEPALIVE:    // 104
                    ProcessGetOnlineCount(sBody);
                    break;

                default:
                    if (nC > 0)
                    {
                        sScoketText = "";
                        break;
                    }
                    nC++;
                    break;
                }
            }
            m_sSockMsg = sScoketText;
        }
Exemple #2
0
        public void AddItemsFromConfig()
        {
            TStringList  LoadList;
            TMonItemInfo MonItem;
            string       s28;
            string       s2C;
            string       s30 = string.Empty;
            int          n18;
            int          n1C;
            int          n20;
            IniFile      ItemIni;
            // ---------------------------读取怪物配置----------------------------------
            string sFileName = M2Share.g_Config.sEnvirDir + "MonUseItems\\" + m_sCharName + ".txt";

            if (File.Exists(sFileName))
            {
                ItemIni = new IniFile(sFileName);
                if (ItemIni != null)
                {
                    m_nButchChargeClass = ItemIni.ReadInteger("Info", "ButchChargeClass", (byte)3); // 收费模式(0金币,1元宝,2金刚石,3灵符)
                    m_nButchChargeCount = ItemIni.ReadInteger("Info", "ButchChargeCount", 1);       // 挖每次收费点数
                    boIntoTrigger       = ItemIni.ReadBool("Info", "ButchCloneItem", false);        // 怪挖是否进入触发
                    // ---------------------------读取探索物品----------------------------------
                    sFileName = M2Share.g_Config.sEnvirDir + "MonUseItems\\" + m_sCharName + "-Item.txt";
                    if (File.Exists(sFileName))
                    {
                        if (m_ButchItemList != null)
                        {
                            if (m_ButchItemList.Count > 0)
                            {
                                for (int I = 0; I < m_ButchItemList.Count; I++)
                                {
                                    if (m_ButchItemList[I] != null)
                                    {
                                        Dispose(m_ButchItemList[I]);
                                    }
                                }
                            }
                            m_ButchItemList.Clear();
                        }
                        LoadList = new TStringList();
                        LoadList.LoadFromFile(sFileName);
                        if (LoadList.Count > 0)
                        {
                            for (int I = 0; I < LoadList.Count; I++)
                            {
                                s28 = LoadList[I];
                                if ((s28 != "") && (s28[0] != ';'))
                                {
                                    s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "/", "\09" });
                                    n18 = HUtil32.Str_ToInt(s30, -1);
                                    s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "/", "\09" });
                                    n1C = HUtil32.Str_ToInt(s30, -1);
                                    s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "\09" });
                                    if (s30 != "")
                                    {
                                        if (s30[0] == '\"')
                                        {
                                            HUtil32.ArrestStringEx(s30, "\"", "\"", ref s30);
                                        }
                                    }
                                    s2C = s30;
                                    s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "\09" });
                                    n20 = HUtil32.Str_ToInt(s30, 1);
                                    if ((n18 > 0) && (n1C > 0) && (s2C != ""))
                                    {
                                        MonItem          = new TMonItemInfo();
                                        MonItem.SelPoint = n18 - 1;
                                        MonItem.MaxPoint = n1C;
                                        MonItem.ItemName = s2C;
                                        MonItem.Count    = n20;
                                        if (HUtil32.Random(MonItem.MaxPoint) <= MonItem.SelPoint) // 计算机率 1/10 随机10<=1 即为所得的物品
                                        {
                                            m_ButchItemList.Add(MonItem);
                                        }
                                    }
                                }
                            }
                        }
                        if (m_ButchItemList.Count > 0)
                        {
                            m_boExploration = true; // 是否可探索
                        }
                        Dispose(LoadList);
                    }
                    Dispose(ItemIni);
                }
            }
        }
Exemple #3
0
        public void Run()
        {
            string       sSocketText   = string.Empty;
            string       sData         = string.Empty;
            string       sBody         = string.Empty;
            string       sCode         = string.Empty;
            const string sExceptionMsg = "{异常} TFrmIdSoc::DecodeSocStr";

            HUtil32.EnterCriticalSection(M2Share.g_Config.UserIDSection);
            if (M2Share.g_Config.sIDSocketRecvText != "" && M2Share.g_Config.sIDSocketRecvText != null)
            {
                try
                {
                    if (M2Share.g_Config.sIDSocketRecvText.IndexOf(")") <= 0)
                    {
                        return;
                    }
                    sSocketText = M2Share.g_Config.sIDSocketRecvText;
                    M2Share.g_Config.sIDSocketRecvText = "";
                }
                finally
                {
                    HUtil32.LeaveCriticalSection(M2Share.g_Config.UserIDSection);
                }
            }
            else
            {
                HUtil32.LeaveCriticalSection(M2Share.g_Config.UserIDSection);
            }
            try
            {
                while (true)
                {
                    sSocketText = HUtil32.ArrestStringEx(sSocketText, "(", ")", ref sData);
                    if (sData == "")
                    {
                        break;
                    }
                    sBody = HUtil32.GetValidStr3(sData, ref sCode, new string[] { "/" });
                    switch (HUtil32.Str_ToInt(sCode, 0))
                    {
                    case Common.SS_OPENSESSION:    // 100
                        GetPasswdSuccess(sBody);
                        break;

                    case Common.SS_CLOSESESSION:    // 101
                        GetCancelAdmission(sBody);
                        break;

                    case Common.SS_KEEPALIVE:    // 104
                        SetTotalHumanCount(sBody);
                        break;

                    case Common.UNKNOWMSG:
                        break;

                    case Common.SS_KICKUSER:    // 111
                        GetCancelAdmissionA(sBody);
                        break;

                    case Common.SS_SERVERLOAD:    // 113
                        GetServerLoad(sBody);
                        break;
                    }
                    if (sSocketText.IndexOf(")") <= 0)
                    {
                        break;
                    }
                }
                HUtil32.EnterCriticalSection(M2Share.g_Config.UserIDSection);
                try
                {
                    M2Share.g_Config.sIDSocketRecvText = sSocketText + M2Share.g_Config.sIDSocketRecvText;
                }
                finally
                {
                    HUtil32.LeaveCriticalSection(M2Share.g_Config.UserIDSection);
                }
            }
            catch
            {
                M2Share.MainOutMessage(sExceptionMsg);
            }
            if (HUtil32.GetTickCount() - dwClearEmptySessionTick > 10000)
            {
                dwClearEmptySessionTick = HUtil32.GetTickCount();
            }
        }
Exemple #4
0
        /// <summary>
        /// 获取DBSERBER发送过来的消息
        /// </summary>
        /// <param name="nQueryID"></param>
        /// <param name="nIdent"></param>
        /// <param name="nRecog"></param>
        /// <param name="sStr"></param>
        /// <param name="dwTimeOut"></param>
        /// <param name="boLoadRcd"></param>
        /// <param name="sName"></param>
        /// <returns></returns>
        public unsafe static bool GetDBSockMsg(int nQueryID, ref int nIdent, ref int nRecog, ref string sStr, uint dwTimeOut, bool boLoadRcd, string sName)
        {
            bool            result;
            bool            boLoadDBOK;
            uint            dwTimeOutTick;
            string          s24        = string.Empty;
            string          s28        = string.Empty;
            string          s2C        = string.Empty;
            string          sCheckFlag = string.Empty;
            string          sDefMsg;
            string          s38;
            int             nLen;
            int             nCheckCode;
            TDefaultMessage DefMsg;
            byte            nCode;
            const string    sLoadDBTimeOut = "[RunDB] 读取人物数据超时...";
            const string    sSaveDBTimeOut = "[RunDB] 保存人物数据超时...";

            boLoadDBOK    = false;
            result        = false;
            dwTimeOutTick = HUtil32.GetTickCount();
            nCode         = 0;
            while (true)
            {
                if ((HUtil32.GetTickCount() - dwTimeOutTick) > dwTimeOut)//dwTimeOut--等待消息的时间
                {
                    nCode = 1;
                    break;
                }
                s24 = "";
                HUtil32.EnterCriticalSection(M2Share.UserDBSection);
                try
                {
                    if (M2Share.g_Config.sDBSocketRecvText.IndexOf("!") > 0)
                    {
                        s24 = M2Share.g_Config.sDBSocketRecvText;
                        M2Share.g_Config.sDBSocketRecvText = "";
                    }
                }
                finally
                {
                    HUtil32.LeaveCriticalSection(M2Share.UserDBSection);
                }
                if (s24 != "")
                {
                    s28 = "";
                    s24 = HUtil32.ArrestStringEx(s24, "#", "!", ref s28);
                    if (s28 != "")
                    {
                        s28  = HUtil32.GetValidStr3(s28, ref s2C, new string[] { "/" });
                        nLen = s28.Length;
                        if ((nLen >= sizeof(TDefaultMessage)) && (HUtil32.Str_ToInt(s2C, 0) == nQueryID))
                        {
                            nCheckCode = HUtil32.MakeLong(HUtil32.Str_ToInt(s2C, 0) ^ 170, nLen);
                            byte[] data = new byte[sizeof(int)];
                            fixed(byte *by = data)
                            {
                                *(int *)by = nCheckCode;
                            }

                            sCheckFlag = EncryptUnit.EncodeBuffer(data, data.Length);
                            if (HUtil32.CompareBackLStr(s28, sCheckFlag, sCheckFlag.Length))
                            {
                                if (nLen == Grobal2.DEFBLOCKSIZE)
                                {
                                    sDefMsg = s28;
                                    s38     = "";
                                }
                                else
                                {
                                    sDefMsg = s28.Substring(0, Grobal2.DEFBLOCKSIZE);
                                    s38     = s28.Substring(Grobal2.DEFBLOCKSIZE + 1 - 1, s28.Length - Grobal2.DEFBLOCKSIZE - 6);
                                }
                                DefMsg     = EncryptUnit.DecodeMessage(sDefMsg);
                                nIdent     = DefMsg.Ident;
                                nRecog     = DefMsg.Recog;
                                sStr       = s38;
                                boLoadDBOK = true;
                                result     = true;
                                break;
                            }
                        }
                        else
                        {
                            if ((nLen < Marshal.SizeOf(typeof(TDefaultMessage))))
                            {
                                nCode = 2;
                            }
                            if ((HUtil32.Str_ToInt(s2C, 0) != nQueryID))
                            {
                                nCode = 4;
                            }
                            M2Share.g_Config.nLoadDBErrorCount++;
                            break;
                        }
                    }
                    else
                    {
                        nCode = 3;
                        M2Share.g_Config.nLoadDBErrorCount++;
                        break;
                    }
                }
                else
                {
                    System.Threading.Thread.Sleep(1);
                }
            }
            if (!boLoadDBOK)
            {
                M2Share.g_nSaveRcdErrorCount++;
                if (boLoadRcd)
                {
                    M2Share.MainOutMessage(sLoadDBTimeOut + sName + " Code:" + nCode);
                }
                else
                {
                    M2Share.MainOutMessage(sSaveDBTimeOut + sName + " Code:" + nCode);
                }
            }
            else
            {
                M2Share.g_nSaveRcdErrorCount = 0;
            }
            M2Share.g_Config.boDBSocketWorking = false;
            return(result);
        }
Exemple #5
0
        public unsafe static bool GetDBSockMsg(byte[] da, int nQueryID, ref int nIdent, ref int nRecog, ref string sStr, uint dwTimeOut, bool boLoadRcd, string sName)
        {
            bool            result;
            bool            boLoadDBOK;
            string          s24        = string.Empty;
            string          s28        = string.Empty;
            string          s2C        = string.Empty;
            string          sCheckFlag = string.Empty;
            string          sDefMsg;
            string          s38;
            int             nLen;
            int             nCheckCode;
            TDefaultMessage DefMsg;

            boLoadDBOK = false;
            result     = false;
            byte      nCode        = 0;
            const int DEFBLOCKSIZE = 32;

            while (true)
            {
                s24 = "";

                try
                {
                    fixed(byte *pb = da)
                    {
                        s24 = HUtil32.SBytePtrToString((sbyte *)pb, 0, da.Length);
                    }

                    s24 = System.Text.Encoding.Default.GetString(da);
                }
                finally
                {
                }
                if (s24 != "")
                {
                    s28 = "";
                    s24 = HUtil32.ArrestStringEx(s24, "#", "!", ref s28);
                    if (s28 != "")
                    {
                        s28  = HUtil32.GetValidStr3(s28, ref s2C, new string[] { "/" });
                        nLen = s28.Length;
                        if ((nLen >= sizeof(TDefaultMessage)) && (HUtil32.Str_ToInt(s2C, 0) == nQueryID))
                        {
                            nCheckCode = HUtil32.MakeLong(HUtil32.Str_ToInt(s2C, 0) ^ 170, nLen);
                            byte[] data = new byte[sizeof(int)];
                            fixed(byte *by = data)
                            {
                                *(int *)by = nCheckCode;
                            }

                            sCheckFlag = EncryptUnit.EncodeBuffer(data, data.Length);
                            if (HUtil32.CompareBackLStr(s28, sCheckFlag, sCheckFlag.Length))
                            {
                                if (nLen == DEFBLOCKSIZE)
                                {
                                    sDefMsg = s28;
                                    s38     = "";
                                }
                                else
                                {
                                    sDefMsg = s28.Substring(0, DEFBLOCKSIZE);
                                    s38     = s28.Substring(DEFBLOCKSIZE + 1 - 1, s28.Length - DEFBLOCKSIZE - 6);
                                }
                                DefMsg     = EncryptUnit.DecodeMessage(sDefMsg);
                                nIdent     = DefMsg.Ident;
                                nRecog     = DefMsg.Recog;
                                sStr       = s38;
                                boLoadDBOK = true;
                                result     = true;
                                break;
                            }
                        }
                        else
                        {
                            if ((nLen < Marshal.SizeOf(typeof(TDefaultMessage))))
                            {
                                nCode = 2;
                            }
                            if ((HUtil32.Str_ToInt(s2C, 0) != nQueryID))
                            {
                                nCode = 4;
                            }
                            break;
                        }
                    }
                    else
                    {
                        nCode = 3;
                        break;
                    }
                }
                else
                {
                    System.Threading.Thread.Sleep(1);
                }
            }
            if (!boLoadDBOK)
            {
                if (boLoadRcd)
                {
                    //M2Share.MainOutMessage(sLoadDBTimeOut + sName + " Code:" + (nCode).ToString());
                }
                else
                {
                    //M2Share.MainOutMessage(sSaveDBTimeOut + sName + " Code:" + (nCode).ToString());
                }
            }
            else
            {
            }
            return(result);
        }
Exemple #6
0
        unsafe static void Main(string[] args)
        {
            GameBaseTest g1 = new GameBaseTest();
            int          n1 = g1.Parse(g1.GameConfig);

            Console.WriteLine(n1);
            Console.ReadKey();
            return;

            GameBaseTest g = new GameBaseTest();

            g.test();
            Thread.Sleep(1000);
            g = new GameBaseTest();
            g.test();
            Console.ReadKey();
            return;

            Console.Write(int.MaxValue);
            Console.ReadKey();
            return;

            int sasdasdasdasd = sizeof(TUnbindInfo);//4491
            int asdasd        = Marshal.SizeOf(typeof(THumDataInfo));


            Console.ReadLine();


            DbSession dbsession = new DbSession("MyTest");


            TDefaultMessage hun     = new TDefaultMessage();
            int             HumSize = Marshal.SizeOf(hun);



            TStdItem a = new TStdItem();

            MyRefTest(a);

            // Console.WriteLine(a.Name);

            IClientScoket socket = new IClientScoket();

            socket.OnConnected      += socket_OnConnected;
            socket.ReceivedDatagram += socket_ReceivedDatagram;
            socket.Connect("127.0.0.1", 6000);

            TDefaultMessage DefMsg = EncryptUnit.MakeDefaultMsg(1000, 0, 0, 0, 0, 0);


            TLoadHuman sLoadHuman   = new TLoadHuman();
            int        aaaaaaaaaaaa = Marshal.SizeOf(sLoadHuman);

            sLoadHuman.sAccount   = "123123";
            sLoadHuman.sChrName   = "啊啊啊啊";
            sLoadHuman.sUserAddr  = "127.0.0.1";
            sLoadHuman.nSessionID = 15;
            byte[] sdata = StructToBytes(sLoadHuman);

            // string sDBMsg = EncryptUnit.EncodeMessage(DefMsg) + EncryptUnit.EncodeBuffer<TLoadHuman>(sLoadHuman);
            //  socket.Send(SendDBSockMsg(0, sDBMsg));

            Console.WriteLine("ok");
            Console.ReadKey();


            //TStdItem a = new TStdItem();
            // MyRefTest(a);
            // Console.WriteLine(a.Name);

            TUnbindInfo abc    = new TUnbindInfo();
            int         MySize = Marshal.SizeOf(abc);

            HUtil32._MIN(Int32.MaxValue, 14 + (int)Math.Floor(1 / (double)6 + 2.5 * 1));

            Math.Round(Math.Round((double)50 / 100, 1), 1);

            decimal aaaaaaaaa = Round((decimal)Round((decimal)50.0 / 100, 1) * 368, 2);



            //string strss=  EncryptUnit.EncodeBuffer(StructToBytes(a, Marshal.SizeOf(typeof(Struct1))), Marshal.SizeOf(typeof(Struct1)));

            Class1 b = new Class1();

            b.Id   = 1;
            b.Name = "张三";

            string strbb = EncryptUnit.EncodeBuffer(ObjectToBytes(b), 8);

            b.Name = "张三";
            //string a = "你好吗";

            //sbyte[] by = new sbyte[StringToSBytePtr(a, null, 1) + 1];
            //fixed (sbyte* pb = by)
            //{
            //    StringToSBytePtr(a, pb, 1);
            //    string b = SBytePtrToString(pb, 1, by.Length - 1);
            //    Console.WriteLine(b);
            //}

            //int nLen = StringToIntPtrPlusLen(a, (IntPtr)0, 0);
            //byte[] byy = new byte[nLen + 1];
            //fixed (byte* pb = byy)
            //{
            //    StringToIntPtrPlusLen(a, (IntPtr)pb, 1);
            //    string b = IntPtrPlusLenToString((IntPtr)pb, 1);
            //    Console.WriteLine(b);
            //}



            Test t = new Test();

            t.Main();

            // THumDataInfo* HumanRcd = (THumDataInfo*)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(THumDataInfo)));

            //byte[] data=new byte[sizeof(THumDataInfo)];
            //fixed (byte* pb = data)
            //{
            //    *(THumDataInfo*)pb = *HumanRcd;
            //}

            TProcessMessage msg = new TProcessMessage();



            int aaaaaaaaaaa = Marshal.SizeOf(typeof(TProcessMessage));



            var arrayDouble = Enumerable.Range(1, 1024)
                              .Select(i => (int)i)
                              .ToArray();

            fixed(int *p = arrayDouble)
            {
                var array2 = ToByte <int>(p, 1);

                //Assert.AreEqual(arrayDouble, array2);
            }

            int[,] arr4 = new int[2, 3] {
                { 1, 2, 3 }, { 4, 5, 6 }
            };


            //byte[, ,] arr = new byte[8,4,4]
            //{
            //    {
            //        {1,2},{1,2}
            //    },
            //    {
            //        {1,2},{1,2}
            //    }
            //};

            byte[, ,] arr = new byte[, , ]
            {
                {
                    { 1, 2 }, { 1, 2 }
                },
                {
                    { 21, 22 }, { 21, 22 }
                },
                {
                    { 31, 32 }, { 31, 32 }
                }
            };


            string sText  = "G73";
            int    nValNo = 0;

            nValNo = HUtil32.Str_ToInt(sText.Substring(1, 2), -1);

            byte[] buff = System.Text.Encoding.GetEncoding("gb2312").GetBytes("我是测试字符串");;
            string str2 = string.Empty;

            for (int i = 0; i < 14; i++)
            {
                str2 += String.Format("{0:X2}", buff[i]) + ",";
            }

            string aa = System.Text.Encoding.GetEncoding("gb2312").GetString(buff);

            Console.WriteLine(str2);
            Console.WriteLine(aa);


            //Console.WriteLine(sizeof(TStdItem));

            //Console.WriteLine(Marshal, sizeof(PTDealOffInfo));

            string str    = string.Empty;
            string FColor = string.Empty;
            string BColor = string.Empty;
            string nTime  = string.Empty;
            string sMsg   = "{180,251} 3 战斗区域";

            sMsg = HUtil32.ArrestStringEx(sMsg, "{", "}", ref str);
            str  = HUtil32.GetValidStrCap(str, ref FColor, new string[] { "," });
            str  = HUtil32.GetValidStrCap(str, ref BColor, new string[] { "," });
            str  = HUtil32.GetValidStrCap(str, ref nTime, new string[] { "," });


            Console.WriteLine(MakeWord((byte)255, (byte)56));

            //m_CanJmpScriptLableList = new List<string>();
            //string msg = @"欢迎,我能为你做点什么?\ \<买/@buy>  物品\<卖/@sell>  物品\<特修毒符/@s_repair>\<询问/@questionprize> 物品详细情况 \<离 开/@exit>\";

            //GetScriptLabel(msg);

            //Console.WriteLine(sizeof(TClientMagic));

            //Console.WriteLine(Marshal.SizeOf(typeof(TClientMagic)));

            //int ccc = sizeof(TClientMagic);

            //@@rmst

            //strLen = sLabel.Substring(0, sLabel.Length - 1);

            //s18 = sLabel.Substring(strLen.Length + 1, sLabel.Length - strLen.Length);

            //Console.WriteLine(m_CanJmpScriptLableList.Count);

            //string aaaa= sub_49ADB8("<$USERNAME>加入游戏,<$SERVERNAME>又多了一份力量!", "<$USERNAME>", "1234");

            //aaaa = sub_49ADB8(aaaa, "<$SERVERNAME>", "12345");



            Console.ReadKey();
        }
Exemple #7
0
        /// <summary>
        /// 读取怪物爆率文件
        /// </summary>
        /// <param name="MonName">怪物名称</param>
        /// <param name="ItemList">物品列表</param>
        /// <returns></returns>
        internal int LoadMonitems(string MonName, ref IList <TMonItem> ItemList)
        {
            int         result = 0;
            TStringList LoadList;
            TMonItem    MonItem;
            string      s28 = string.Empty;
            string      s2C = string.Empty;
            string      s30 = string.Empty;
            int         n18;
            int         n1C;
            int         n20;
            string      sFileName = M2Share.g_Config.sEnvirDir + "MonItems\\" + MonName + ".txt";

            if (File.Exists(sFileName))
            {
                if (ItemList != null)
                {
                    if (ItemList.Count > 0)
                    {
                        for (int I = 0; I < ItemList.Count; I++)
                        {
                            if (ItemList[I] != null)
                            {
                                Dispose(ItemList[I]);
                            }
                        }
                    }
                    ItemList.Clear();
                }
                LoadList = new TStringList();
                LoadList.LoadFromFile(sFileName);
                for (int I = 0; I < LoadList.Count; I++)
                {
                    s28 = LoadList[I];
                    if ((s28 != "") && (s28[0] != ';'))
                    {
                        s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "/", "\t" });
                        n18 = HUtil32.Str_ToInt(s30, -1);
                        s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "/", "\t" });
                        n1C = HUtil32.Str_ToInt(s30, -1);
                        s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "\t" });
                        if (s30 != "")
                        {
                            if (s30[0] == '\'')
                            {
                                HUtil32.ArrestStringEx(s30, "\"", "\"", ref s30);
                            }
                        }
                        s2C = s30;
                        s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "\t" });
                        n20 = HUtil32.Str_ToInt(s30, 1);
                        if ((n18 > 0) && (n1C > 0) && (s2C != ""))
                        {
                            if (ItemList == null)
                            {
                                ItemList = new List <TMonItem>();
                            }
                            MonItem          = new TMonItem();
                            MonItem.n00      = n18 - 1;
                            MonItem.n04      = n1C;
                            MonItem.sMonName = s2C;
                            MonItem.n18      = n20;
                            ItemList.Add(MonItem);
                            result++;
                        }
                    }
                }
            }
            return(result);
        }
Exemple #8
0
        private void MSocket_OnClientRead(object sender, AsyncSockets.AsyncUserToken e)
        {
            int I;
            TMsgServerInfo MsgServer;
            string sReviceMsg = string.Empty;
            string sMsg = string.Empty;
            string sCode = string.Empty;
            string sAccount = string.Empty;
            string sServerName = string.Empty;
            string sIndex = string.Empty;
            string sOnlineCount = string.Empty;
            int nCode;
            TConfig Config;
            Config = LSShare.g_Config;
            if (TFrmMain.Colsed) return;
            HUtil32.EnterCriticalSection(objRead);
            try
            {
                for (I = 0; I < m_ServerList.Count; I++)
                {
                    MsgServer = m_ServerList[I];
                    if (MsgServer.Socket == e)
                    {
                        //string ReceiveText = Encoding.Default.GetString(e.ReceiveBuffer, 0, e.BytesReceived);
                        //if (ReceiveText[0] == '\0') ReceiveText = "";
                        byte[] data = new byte[e.BytesReceived];
                        Array.Copy(e.ReceiveBuffer, e.Offset, data, 0, e.BytesReceived);
                        string ReceiveText = Encoding.Default.GetString(data);

                        sReviceMsg = MsgServer.sReceiveMsg + ReceiveText;
                        while ((sReviceMsg.IndexOf(')') > 0))
                        {
                            sReviceMsg = HUtil32.ArrestStringEx(sReviceMsg, "(", ")", ref sMsg);
                            if (sMsg == "")
                            {
                                break;
                            }
                            sMsg = HUtil32.GetValidStr3(sMsg, ref sCode, new string[] { "/" });
                            nCode = HUtil32.Str_ToInt(sCode, -1);
                            switch (nCode)
                            {
                                case Common.SS_SOFTOUTSESSION:
                                    sMsg = HUtil32.GetValidStr3(sMsg, ref sAccount, new string[] { "/" });
                                    FrmMain.CloseUser(Config, sAccount, HUtil32.Str_ToInt(sMsg, 0));
                                    break;

                                case Common.SS_SERVERINFO:
                                    sMsg = HUtil32.GetValidStr3(sMsg, ref sServerName, new string[] { "/" });
                                    sMsg = HUtil32.GetValidStr3(sMsg, ref sIndex, new string[] { "/" });
                                    sMsg = HUtil32.GetValidStr3(sMsg, ref sOnlineCount, new string[] { "/" });
                                    MsgServer.sServerName = sServerName;
                                    MsgServer.nServerIndex = HUtil32.Str_ToInt(sIndex, 0);
                                    MsgServer.nOnlineCount = HUtil32.Str_ToInt(sOnlineCount, 0);
                                    MsgServer.dwKeepAliveTick = HUtil32.GetTickCount();
                                    MsgServer.sIPaddr = e.EndPoint.Address.ToString() + ":" + e.EndPoint.Port.ToString();
                                    SortServerList(I);
                                    LSShare.nOnlineCountMin = GetOnlineHumCount();
                                    if (LSShare.nOnlineCountMin > LSShare.nOnlineCountMax)
                                    {
                                        LSShare.nOnlineCountMax = LSShare.nOnlineCountMin;
                                    }
                                    SendServerMsgA(Common.SS_KEEPALIVE, (LSShare.nOnlineCountMin).ToString());
                                    RefServerLimit(sServerName);
                                    break;

                                case Common.UNKNOWMSG:
                                    SendServerMsgA(Common.UNKNOWMSG, sMsg);
                                    break;

                                case Common.SS_ADDIPTOGATE:
                                    FrmMain.SendIPToGate(sMsg);
                                    break;
                            }
                        }
                    }

                    MsgServer.sReceiveMsg = sReviceMsg;

                    //MessageBox.Show(m_ServerList[I].sReceiveMsg);
                    //m_ServerList[I] = MsgServer;
                }
            }
            finally
            {
                HUtil32.LeaveCriticalSection(objRead);
            }
        }