Пример #1
0
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            string GIP = "";

            if (PressGame == false)
            {
                GIP = frmClient.ToGameIP((PictureBox)sender);
                if (GIP == null)
                {
                    GIP = "";
                }
                if (GIP != "")
                {
                    temMsg.sendKind    = SendKind.SendCommand;
                    temMsg.msgCommand  = MsgCommand.BegingRival;
                    temMsg.DeskMark    = ((PictureBox)sender).Name;
                    ClientClass.GameIP = GIP;
                    GIP = GIP.Substring(0, GIP.IndexOf('|'));

                    temMsg.SIP = GIP.Trim();

                    udpSocket1.Send(IPAddress.Parse(GIP), 11001, new ClassSerializers().SerializeBinary(frmClient.Game_FarInfo(GIP)).ToArray());
                }
                else
                {
                    ClientClass.GameIP       = "";
                    ClientClass.GamePort     = "11001";
                    ClientClass.GameName     = "";
                    ClientClass.GameFraction = "";
                    ClientClass.GameCaput    = "";
                    ClientClass.GameSex      = "";
                }
                temMsg    = null;
                temMsg    = frmClient.DeskHandle(((PictureBox)sender), imageList1, 1);
                PressGame = true;

                //发送消息
                udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), 11000, new ClassSerializers().SerializeBinary(temMsg).ToArray());
            }
        }
Пример #2
0
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            string GIP = "";

            if (PressGame == false)                                 //判断当前用户是否已进入“对决”窗口
            {
                GIP = frmClient.ToGameIP((PictureBox)sender);       //获取对方玩家的IP地址
                if (GIP == null)                                    //如果获取的信息为null
                {
                    GIP = "";                                       //设置为空
                }
                if (GIP != "")                                      //如果对面座位有人
                {
                    temMsg.sendKind    = SendKind.SendCommand;      //设置发送命令
                    temMsg.msgCommand  = MsgCommand.BegingRival;    //设置消息为BegingRival
                    temMsg.DeskMark    = ((PictureBox)sender).Name; //获取座位名
                    ClientClass.GameIP = GIP;                       //获取对方的IP地址
                    GIP        = GIP.Substring(0, GIP.IndexOf('|'));
                    temMsg.SIP = GIP.Trim();
                    //发送信息
                    udpSocket1.Send(IPAddress.Parse(GIP), 11001, new ClassSerializers().SerializeBinary(frmClient.Game_FarInfo(GIP)).ToArray());
                }
                else
                {
                    ClientClass.GameIP       = "";
                    ClientClass.GamePort     = "11001";
                    ClientClass.GameName     = "";
                    ClientClass.GameFraction = "";
                    ClientClass.GameCaput    = "";
                    ClientClass.GameSex      = "";
                }
                temMsg    = null;                                                      //清空ClassMsg对象列表
                temMsg    = frmClient.DeskHandle(((PictureBox)sender), imageList1, 1); //获取当前桌的信息
                PressGame = true;
                //发送消息
                udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), 11000, new ClassSerializers().SerializeBinary(temMsg).ToArray());
            }
        }