コード例 #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
        private static void ProcessContactReplace(N1mmXmlContactReplace cr)
        {
            int    band = (int)cr.Band;
            string call = cr.Call;

            AddLogEntryToWorkedBandSquares(call, band);
        }
コード例 #3
0
        public static bool TryParse(byte[] datagram, out N1mmXmlContactReplace contactReplace)
        {
            string str;

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

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

            return(true);
        }