示例#1
0
文件: Program.cs 项目: M0LTE/ft8push
        static void ProcessQueue()
        {
            while (true)
            {
                byte[] msg = null;
                lock (n1mmBuffer)
                {
                    if (n1mmBuffer.Count > 0)
                    {
                        msg = n1mmBuffer.Dequeue();
                    }
                }

                if (msg != null)
                {
                    if (N1mmXmlContactReplace.TryParse(msg, out N1mmXmlContactReplace cr))
                    {
                        ProcessContactReplace(cr);
                    }
                    else if (N1mmXmlContactInfo.TryParse(msg, out N1mmXmlContactInfo ci))
                    {
                        ProcessContactAdd(ci);
                    }
                }
                else
                {
                    Thread.Sleep(1000);
                }
            }
        }
示例#2
0
文件: Program.cs 项目: M0LTE/ft8push
        static void ProcessContactAdd(N1mmXmlContactInfo ci)
        {
            int    band = (int)ci.Band;
            string call = ci.Call;

            AddLogEntryToWorkedBandSquares(call, band);
        }
示例#3
0
        public static bool TryParse(byte[] datagram, out N1mmXmlContactInfo contactInfo)
        {
            string str;

            try
            {
                str = Encoding.UTF8.GetString(datagram);
            }
            catch (Exception ex)
            {
                Log("Exception: {0}", ex);
                contactInfo = null;
                return(false);
            }

            try
            {
                var serialiser = new XmlSerializer(typeof(N1mmXmlContactInfo));
                using (var reader = new StringReader(str))
                {
                    contactInfo = (N1mmXmlContactInfo)serialiser.Deserialize(reader);
                }
            }
            catch (Exception ex)
            {
                Log("Exception: {0}", ex);
                contactInfo = null;
                return(false);
            }

            return(true);
        }