Example #1
0
 public TFrmMsgClient()
 {
     InitializeComponent();
     MsgClient = new IClientScoket();
     MsgClient.ReceivedDatagram += new DSCClientOnDataInHandler(MsgClientRead);
     MsgClient.OnConnected      += new DSCClientOnConnectedHandler(MsgClientConnect);
 }
Example #2
0
        /// <summary>
        /// 窗器载入事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TFrmIDSoc_Load(object sender, EventArgs e)
        {
            IDSocket                   = new IClientScoket();
            IDSocket.OnConnected      += IDSocket_OnConnected;
            IDSocket.OnDisconnected   += IDSocket_OnDisconnected;
            IDSocket.OnError          += IDSocket_OnError;
            IDSocket.ReceivedDatagram += IDSocket_ReceivedDatagram;

            GlobaSessionList       = new List <TGlobaSessionInfo>();
            m_sSockMsg             = "";
            m_Module               = null;
            m_dwCheckServerTimeMin = HUtil32.GetTickCount();
            m_dwCheckServerTimeMax = 0;
            m_dwCheckRecviceTick   = HUtil32.GetTickCount();

            ReConnectTimer = new System.Threading.Timer(ReConnectTimerTimer, null, -1, -1);
            KeepAliveTimer = new System.Threading.Timer(KeepAliveTimerTimer, null, -1, -1);
        }
Example #3
0
        private unsafe void button1_Click(object sender, EventArgs e)
        {
            var saasdasdasdasd = "天魔神甲".Length;
            var sdasdsad       = HUtil32.GetStrLength("天魔神甲");

            IClientScoket socket = new IClientScoket();

            socket.OnConnected += socket_OnConnected;

            socket.Connect("127.0.0.1", 6000);
            socket.ReceivedDatagram += socket_ReceivedDatagram;
            TLoadHuman sLoadHuman = new TLoadHuman();

            sLoadHuman.sAccount   = "123123";
            sLoadHuman.sChrName   = "阿斯顿23";
            sLoadHuman.sUserAddr  = "127.0.0.1";
            sLoadHuman.nSessionID = 15;

            string sDBMsg = EncryptUnit.EncodeMessage(EncryptUnit.MakeDefaultMsg(1000, 0, 0, 0, 0, 0)) + EncryptUnit.EncodeBuffer <TLoadHuman>(sLoadHuman);

            socket.Send(SendDBSockMsg(0, sDBMsg));
        }
Example #4
0
        public TFrmIDSoc()
        {
            InitializeComponent();
            IniFile Conf;

            if (File.Exists(M2Share.sConfigFileName))
            {
                Conf = new IniFile(M2Share.sConfigFileName);
                if (Conf != null)
                {
                    IDSrvAddr = Conf.ReadString("Server", "IDSAddr", "127.0.0.1");
                    IDSrvPort = Conf.ReadInteger("Server", "IDSPort", 5600);
                }
            }
            else
            {
                MessageBox.Show("配置文件" + M2Share.sConfigFileName + "未找到!!!");
            }
            m_SessionList = new List <TSessInfo>();
            M2Share.g_Config.boIDSocketConnected = false;
            IDSocket                   = new IClientScoket();
            IDSocket.OnConnected      += new DSCClientOnConnectedHandler(IDSocketConnect);
            IDSocket.ReceivedDatagram += new DSCClientOnDataInHandler(IDSocketRead);
        }
Example #5
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();
        }