Exemplo n.º 1
0
 /// <summary>
 /// Called by leader through Communicate()
 /// </summary>
 internal static void ServerUpdate()
 {
     if (!Enabled)
     {
         return;
     }
     // Need to initialize server service
     if (Host == null || (Host != null && Host.State != CommunicationState.Opened))
     {
         StartServer();
     }
     // Server service initialized, lets update
     if (Leader.GetMillisecondsSinceLastUpdate() >= 500)
     {
         Leader = Message.GetMessage();
         if (Followers.Any())
         {
             Leader.HighestTeamRiftKey = Followers.Min(f => f.Value.HighestLevelTieredRiftKey);
         }
         SharedComposites.CheckReplaceOutOfGameHook();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Called by followers through FollowTag->Communicate()
        /// </summary>
        private static void ClientUpdate()
        {
            if (Enabled)
            {
                _updateRunning = true;
                try
                {
                    if (Host != null && Host.State == CommunicationState.Opened)
                    {
                        Logr.Log("Shutting down Server Service");
                        Host.Close();
                        Host = null;
                    }
                }
                catch (Exception ex)
                {
                    Logr.Error("Error shutting down server service: " + ex);
                }

                StartClient();

                try
                {
                    if (Initialized && Leader.GetMillisecondsSinceLastUpdate() >= 250)
                    {
                        // Get the leader message and store it
                        Leader = HttpProxy.GetUpdate();

                        // Send our follower message to the leader
                        HttpProxy.SendUpdate(_lastMessage);


                        if (LastLeaderUpdateMessage == null || LastLeaderUpdateMessage != Leader)
                        {
                            LastLeaderUpdateMessage = Leader;

                            SetQuestToolsOptionsFromLeader();

                            if (Settings.Instance.DebugLogging)
                            {
                                Logr.Debug("Leader {0}", Leader.ToString());
                            }
                        }
                    }
                }
                catch (EndpointNotFoundException ex)
                {
                    Logr.Error("Error 201: Could not get an update from the leader using {0}. Is the leader running? ({1})", HttpFactory.Endpoint.Address.Uri.AbsoluteUri, ex.Message);
                    Initialized = false;
                }
                catch (CommunicationException ex)
                {
                    Logr.Error("Error 202: Could not get an update from the leader using {0}. Is the leader running? ({1})", HttpFactory.Endpoint.Address.Uri.AbsoluteUri, ex.Message);
                    Initialized = false;
                }
                catch (Exception ex)
                {
                    Logr.Error("Error 203: Could not get an update from the leader using {0}. Is the leader running?", HttpFactory.Endpoint.Address.Uri.AbsoluteUri);
                    Initialized = false;
                    Logr.Log(ex.ToString());
                }
                _updateRunning = false;
            }
        }