示例#1
0
文件: Program.cs 项目: rba100/foosnet
        static void Main(string[] args)
        {
            CommunicatorIntegration ci = new CommunicatorIntegration();
            ci.StatusChanged += StatusChanged_EventHandler;
            ci.StatusChangedSubscribeEmail(ci.GetLocalUserEmail());
            ci.StatusChangedSubscribeEmail("*****@*****.**");

            new System.Threading.AutoResetEvent(false).WaitOne();
        }
示例#2
0
        public NotifyWindowViewModel()
        {
            // Load settings
            var endpoint = ConfigurationManager.AppSettings["networkServiceEndpoint"];
            var savedPriorities = Settings.Default.Priorities ?? new StringCollection();
            m_DesiredPlayerOrder = savedPriorities.Cast<string>().ToList();
            UseMinimalAlerts = Settings.Default.UseMinimalAlerts;

            m_PlayerProcessors = new List<IPlayerTransformation>();
            m_PlayerProcessors.Add(new DefaultNameTransformation());

            var localEmail = (Environment.UserName + "@" + Environment.UserDomainName + ".com").ToLowerInvariant();
            m_Self = new FoosPlayerListItem(localEmail, Status.Available, 1) { DisplayName = "You" };

            try
            {
                m_Communicator = new CommunicatorIntegration.CommunicatorIntegration();
                m_PlayerProcessors.Add(new CommunicatorPlayerFilter(m_Communicator));
                m_Communicator.StatusChanged += CommunicatorOnStatusChanged;
                localEmail = m_Communicator.GetLocalUserEmail();
            }
            catch
            {
                // If Communicator isn't working, process player names as best we can from email address
                m_PlayerProcessors.Add(new StatusToUnknownTransformation());
                m_Communicator = null;
                var samurai = new Thread(HonourableSamurai);
                samurai.Start();
            }

            // nasty hack to support WPF designer
            if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                m_NetworkService = new TestFoosNetworkService();
            }
            else
            {
                m_NetworkService = new FoosNetworkService(endpoint, localEmail, TimeSpan.FromMinutes(1));
            }

            m_FoosPlayers.CollectionChanged += FoosPlayersOnCollectionChanged;
            m_NetworkService.PlayersDiscovered += NetworkServiceOnPlayersDiscovered;
            m_NetworkService.GameStarting += NetworkServiceOnGameStarting;
            m_NetworkService.TableStatusChanged += NetworkServiceOnTableStatusChanged;

            GameManager = new GameManager(m_NetworkService, this, m_FoosPlayers, m_Self);
            GameManager.PropertyChanged += GameManagerOnPropertyChanged;
            GameManager.OnError += GameManagerOnOnError;
        }
示例#3
0
 // Kill self if Office communicator comes online
 private void HonourableSamurai()
 {
     while (true) // to oneself
     {
         Thread.Sleep(60000);
         try
         {
             m_Communicator = new CommunicatorIntegration.CommunicatorIntegration();
             var test = m_Communicator.GetLocalUserEmail();
             // Looks like it's working! better kill myself.
             string fullPath = System.Reflection.Assembly.GetAssembly(typeof(NotifyWindowViewModel)).Location;
             Process.Start(fullPath);
             Environment.Exit(0); // Serious business
         }
         catch
         {
             // Try once again in a bit
         }
     }
 }
 public CommunicatorPlayerFilter(CommunicatorIntegration communicatorIntegration)
 {
     m_CommunicatorIntegration = communicatorIntegration;
 }