Example #1
0
        void UdpHandler()
        {
            IPEndPoint _toEndPoint = new IPEndPoint(IPAddress.Any, 0);

            byte[] data = _myUdpClient.Receive(ref _toEndPoint);

            AR_InfoHead reciveHead = InfoAnalyze.GetInfoHead(data);

            //收到,发送反馈包
            byte[] feedback = InfoAnalyze.GetFeedbackBytes(reciveHead);
            _myUdpClient.Send(feedback, feedback.Length, _toEndPoint);

            //组织各种包数据 - 发送
            if (reciveHead.TaskNum < 30)
            {
                //任务码10:人员信息 //任务码15:赛程安排 //任务码20:站位表
                int    phaseId  = InfoAnalyze.GetReceiveInt32(data);//默认为0
                byte[] sendData = InfoAnalyze.GetSendBytes(reciveHead, phaseId);
                _myUdpClient.Send(sendData, sendData.Length, _toEndPoint);
            }
            else if (reciveHead.TaskNum == 30)// &&CurMatchInfo.MatchStatusID == 50) // 接收成绩数据
            {
                InfoAnalyze.InsertArrowResultToOvr(data);
            }
            else if (reciveHead.TaskNum == 31)// && CurMatchInfo.MatchStatusID == 50) // 接收附加赛成绩数据
            {
                InfoAnalyze.InsertArrowShootOffToOvr(data);
            }
        }
Example #2
0
        public static byte[] GetSendBytes(AR_InfoHead head, int para)
        {
            AR_InfoHead sendHead = new AR_InfoHead();

            sendHead.HeadMark    = head.HeadMark;
            sendHead.EndMark     = head.EndMark;
            sendHead.ConfirmMark = head.ConfirmMark;
            sendHead.TaskNum    += head.TaskNum + 1;
            string strData = string.Empty;

            switch (head.TaskNum)
            {
            case 10:
                strData = GVAR.g_ManageDB.InterfaceGetRegisterInfo(GVAR.g_strDisplnCode);
                break;

            case 15:
                strData = GVAR.g_ManageDB.InterfaceGetScheduleInfo(GVAR.g_strDisplnCode);
                break;

            case 20:
                strData = GVAR.g_ManageDB.InterfaceGetMatchStartList(para);
                break;
            }
            byte[] dataBytes = Encoding.UTF8.GetBytes(strData);
            sendHead.InfoLength = dataBytes.Length;
            byte[] sendData = InfoAnalyze.GetPackageBytes(sendHead, dataBytes);

            return(sendData);
        }
Example #3
0
        public static byte[] GetFeedbackBytes(AR_InfoHead head)
        {
            AR_InfoHead fdHead = new AR_InfoHead();

            fdHead.HeadMark    = head.HeadMark;
            fdHead.EndMark     = head.EndMark;
            fdHead.ConfirmMark = head.ConfirmMark;
            fdHead.TaskNum     = 254;
            byte[] data = Encoding.UTF8.GetBytes(head.ConfirmMark.ToString());
            return(GetPackageBytes(fdHead, data));
        }
Example #4
0
        public static byte[] GetPackageBytes(AR_InfoHead head, byte[] data)
        {
            byte[] hmByte      = BitConverter.GetBytes(head.HeadMark);
            byte[] taskByte    = BitConverter.GetBytes(head.TaskNum);
            byte[] confirmByte = BitConverter.GetBytes(head.ConfirmMark);
            byte[] lenghByte   = BitConverter.GetBytes(data.Length);
            byte[] lastByte    = BitConverter.GetBytes(head.EndMark);

            byte[] sendData = new byte[hmByte.Length + taskByte.Length +
                                       confirmByte.Length + lenghByte.Length + data.Length + lastByte.Length];

            hmByte.CopyTo(sendData, 0);
            taskByte.CopyTo(sendData, hmByte.Length);
            confirmByte.CopyTo(sendData, hmByte.Length + taskByte.Length);
            lenghByte.CopyTo(sendData, hmByte.Length + taskByte.Length + confirmByte.Length);
            data.CopyTo(sendData, hmByte.Length + taskByte.Length + confirmByte.Length + lenghByte.Length);
            lastByte.CopyTo(sendData, hmByte.Length + taskByte.Length + confirmByte.Length + lenghByte.Length + data.Length);
            return(sendData);
        }
Example #5
0
        public static AR_InfoHead GetInfoHead(byte[] data)
        {
            AR_InfoHead head = new AR_InfoHead();

            try
            {
                if (data.Length >= 4)
                {
                    head.HeadMark = BitConverter.ToInt32(data, 0);
                    //head.HeadMark = Convert.ToInt32(Encoding.UTF8.GetString(data, 0, 4));
                }
                if (data.Length >= 8)
                {
                    head.TaskNum = BitConverter.ToInt32(data, 4);
                    //Encoding.UTF8.GetString(data, 4, 4);
                    //head.TaskNum = Convert.ToInt32(strTask);
                }
                if (data.Length >= 12)
                {
                    head.ConfirmMark = BitConverter.ToInt32(data, 8);
                    //head.ConfirmMark = Convert.ToInt32(Encoding.UTF8.GetString(data, 8, 4));
                }
                if (data.Length >= 16)
                {
                    head.InfoLength = BitConverter.ToInt32(data, 12);
                    //head.InfoLength = Convert.ToInt32(Encoding.UTF8.GetString(data, 12, 4));
                }
                if (data.Length >= 20)
                {
                    head.EndMark = BitConverter.ToInt32(data, data.Length - 4);
                    //head.InfoLength = Convert.ToInt32(Encoding.UTF8.GetString(data, 12, 4));
                }
            }
            catch { }
            return(head);
        }
Example #6
0
 public static byte[] GetSendBytes(AR_InfoHead head)
 {
     return(GetSendBytes(head, 0));
 }