Esempio n. 1
0
        private void SendOverRankInfo()
        {
            stPkgHead head = new stPkgHead();

            head.iSytle = 80;
            RankInfo[] info   = new RankInfo[ships.Length];
            byte[]     buffer = new byte[ships.Length * RankInfo.TotolLength];

            for (int i = 0; i < ships.Length; i++)
            {
                info[i].Score = ships[i].Score;
                info[i].Rank  = 0;
                info[i].Name  = new char[RankInfo.NameLength];

                for (int j = 0; j < ships[i].PlayerName.Length; j++)
                {
                    info[i].Name[j] = ships[i].PlayerName[j];
                }

                byte[] temp = SocketMgr.StructToBytes(info[i]);
                temp.CopyTo(buffer, i * RankInfo.TotolLength);
            }

            MemoryStream stream = new MemoryStream();

            stream.Write(buffer, 0, buffer.Length);
            head.dataSize = buffer.Length;

            SocketMgr.SendCommonPackge(head, stream);
            stream.Close();
        }
Esempio n. 2
0
        void btnLogin_OnPress(object sender, EventArgs e)
        {
            if (wait != 0)
            {
                return;
            }

            LoginData data;

            data.Name = new char[21];
            char[] temp = namebox.text.ToCharArray();
            for (int i = 0; i < temp.Length; i++)
            {
                data.Name[i] = temp[i];
            }


            data.Password = new char[21];
            temp          = passbox.text.ToCharArray();
            for (int i = 0; i < temp.Length; i++)
            {
                data.Password[i] = temp[i];
            }
            stPkgHead    head   = new stPkgHead();
            MemoryStream Stream = new MemoryStream();

            Stream.Write(SocketMgr.StructToBytes(data), 0, LoginData.size);
            head.dataSize = (int)Stream.Length;
            head.iSytle   = 10;

            SocketMgr.ConnectToServer();
            SocketMgr.StartReceiveThread();
            SocketMgr.SendCommonPackge(head, Stream);
            Stream.Close();

            wait++;
        }