예제 #1
0
        private void monitorMyLocation()
        {
            try {
                while (true)
                {
                    if (discloseLocation)
                    {
                        Trace.WriteLine("DEBUG: Looking up location info..");
                        try {
                            MSE.login();
                            AesMobileStationLocation loc = MSE.queryMAC(myMac);
                            MSE.logout();

                            if (loc != null)
                            {
                                if ((prevLoc == null) || (prevLoc.x != loc.x) || (prevLoc.y != loc.y))
                                {
                                    TXTrecords.Add("locationID", "NOTIMPL" /* loc.x + " x " + loc.y */);
                                    publishService.setTXTRecordData(NetService.DataFromTXTRecordDictionary(TXTrecords));

                                    Trace.WriteLine(" Mac: " + loc.macAddress + " Loc: " + loc.x + "x" + loc.y + " lastHeard " + loc.minLastHeardSecs + " conf " + loc.confidenceFactor);
                                    prevLoc = loc;
                                }
                            }
                        } catch (Exception e) {
                            Trace.WriteLine("DEBUG: Disclose location: " + e.StackTrace);
                        }
                    }
                    Thread.Sleep(5000);
                }
            } catch (Exception e) {
                Trace.WriteLine("Oops - " + e.Message);
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        public static void monitorMyLocation()
        {
            /* TextBox locationString = (TextBox)o;
             * if (locationString.GetType() != typeof(TextBox)) {
             *   Trace.WriteLine("Hmmm, not the right type");
             *   return;
             * }
             */
            while (true)
            {
                using (RegistryKey dcs = Registry.CurrentUser.CreateSubKey("Software").CreateSubKey("FXPAL").CreateSubKey("DisplayCast").CreateSubKey("Player")) {
                    discloseLocation = Convert.ToBoolean(dcs.GetValue("discloseLocation", false));
                }

                if (discloseLocation)
                {
                    // Trace.WriteLine("DEBUG: Looking up location info..");
                    try {
                        MSE.login();
                        AesMobileStationLocation loc = MSE.queryMAC(myMac);
                        MSE.logout();

                        if (loc != null)
                        {
                            if ((prevLoc == null) || (prevLoc.x != loc.x) || (prevLoc.y != loc.y))
                            {
                                TXTrecords.Add("locationID", "NOTIMPL" /* loc.x + " x " + loc.y */);
                                nsPublisher.TXTRecordData = NetService.DataFromTXTRecordDictionary(TXTrecords);

                                Trace.WriteLine(" Mac: " + loc.macAddress + " Loc: " + loc.x + "x" + loc.y + " lastHeard " + loc.minLastHeardSecs + " conf " + loc.confidenceFactor);
                                prevLoc = loc;
                            }
                        }
                    } catch (Exception e) {
                        Trace.WriteLine("DEBUG: Disclose location: " + e.StackTrace);
                    }
                }

                Thread.Sleep(5000);
            }
        }