Ejemplo n.º 1
0
        public virtual void Listner(ushort Destination)
        {
            while (m_running)
            {
                try
                {
                    data = m_newsock.Receive(ref m_sender);
                    pMsgCallback(UDP_MSGCB.MSG_RECIVED, AppCommon.UDP_MESSAGE_CODES.NONE, null, 0);
                    AppCommon.ByteArrayToStruct <AppCommon.UDPMessageHeader>(data, ref m_uHeader);
                    if (m_uHeader.StartCode1 == 0x1122 && m_uHeader.StartCode2 == 0x3344 && m_uHeader.Destination == Destination)
                    {
                        AppCommon.ByteArrayToStruct <AppCommon.UPayload>(data, ref m_uPayload);
                        Array.Copy(data, Marshal.SizeOf(m_uHeader) + 2, m_rbuffer, 0, m_uHeader.size);
                        pMsgCallback(UDP_MSGCB.DATA_RECIVED, m_uPayload.msgCodes, m_rbuffer, m_uHeader.size);

                        /*
                         * if (m_uPayload.msgCodes == AppCommon.UDP_MESSAGE_CODES.SET_SIGNAL_ID)
                         * {
                         *  float value = BitConverter.ToSingle(m_rbuffer, 0);
                         *  pMsgCallback(UDP_MSGCB.DATA_RECIVED, m_uPayload.msgCodes, m_uHeader, m_uPayload, value.ToString());
                         * }
                         * if (m_uPayload.msgCodes == AppCommon.UDP_MESSAGE_CODES.START_FECTH_ACK)
                         * {
                         *  pMsgCallback(UDP_MSGCB.DATA_RECIVED,m_uPayload.msgCodes,  m_uHeader, m_uPayload, string.Empty);
                         * }
                         */
                    }
                }
                catch (Exception)
                {
                    if (m_running == false)
                    {
                        return;
                    }
                }
            }
        }